Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick fix for Wrong Test method with last Nunit3TestAdapter #57 #58

Merged
merged 2 commits into from
Mar 18, 2018

Conversation

bhugot
Copy link
Contributor

@bhugot bhugot commented Mar 18, 2018

As I wrote it in the issue we should do a small instrumentation on Test assemblies that would add an attribute on hit so that we don't need to know tests frameworks
Also would improve execution as then we don't need to instrument every thing with the try catch only the Test assemblies

@@ -31,10 +44,15 @@ private static bool HasPdb(MethodBase methodBase)
lock (Lock)
{
if (AssemblyHasPdbCache.TryGetValue(location, out var hasPdb)) return hasPdb;
hasPdb = File.Exists(Path.ChangeExtension(location, ".pdb"));
hasPdb = IsNotATestFrameworkAssembly(methodBase.DeclaringType.Assembly) && File.Exists(Path.ChangeExtension(location, ".pdb"));
Copy link
Owner

@lucaslorentz lucaslorentz Mar 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename hasPdb to isUserAssembly. Or something different.
Not a blocker.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I was thinking the same


private static bool IsNotATestFrameworkAssembly(Assembly assembly)
{
return !TestFrameworkAssemblies.Any(framework => assembly.GetName().Name.Equals(framework, StringComparison.InvariantCultureIgnoreCase));
Copy link
Owner

@lucaslorentz lucaslorentz Mar 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this method might be called several times in some situations, maybe it's better to use a Hashset and lose the IgnoreCase comparison. O(1) vs O(n)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree

AssemblyHasPdbCache.Add(location, hasPdb);
return hasPdb;
}
}

private static bool IsNotATestFrameworkAssembly(Assembly assembly)
Copy link
Owner

@lucaslorentz lucaslorentz Mar 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I slightly prefer a positive method: IsTestFrameworkAssembly
And negate where we call the method.
But this is not a blocker.

@lucaslorentz lucaslorentz merged commit cb94c3b into lucaslorentz:master Mar 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants