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

Fixes navigation for base class methods declared in other assemblies #174

Merged
merged 9 commits into from
May 15, 2017

Conversation

ajryan
Copy link
Contributor

@ajryan ajryan commented May 3, 2017

Fix for #163

@msftclas
Copy link

msftclas commented May 3, 2017

@ajryan,
Thanks for having already signed the Contribution License Agreement. Your agreement was validated by Microsoft. We will now review your pull request.
Thanks,
Microsoft Pull Request Bot

if (!method.DeclaringType.FullName.Equals(this.type.FullName))
{
testMethod.DeclaringClassFullName = method.DeclaringType.FullName;
}

if (!this.reflectHelper.IsMethodDeclaredInSameAssemblyAsType(method, this.type))
Copy link
Contributor

Choose a reason for hiding this comment

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

How about passing this in from the parent caller when it calls GetTestFromMethod? Wouldn't need to query for it again then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. I was thinking since it's internal the method could be used outside GetTests but it's only called by unit tests, so OK.

@@ -80,15 +80,29 @@ internal UnitTestDiscoverer()

internal void SendTestCases(string source, IEnumerable<UnitTestElement> testElements, ITestCaseDiscoverySink discoverySink)
{
object navigationSession = null;
Dictionary<string, object> navigationSessions = new Dictionary<string, object>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Am loving this. 👍 Performance is one of our key pillars. Although we haven't heard much in terms of performance issues in mstest v2, we learnt the hard way that this could hit us hard down the line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:)

@@ -80,15 +80,29 @@ internal UnitTestDiscoverer()

internal void SendTestCases(string source, IEnumerable<UnitTestElement> testElements, ITestCaseDiscoverySink discoverySink)
{
object navigationSession = null;
Dictionary<string, object> navigationSessions = new Dictionary<string, object>();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this can be a var instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@@ -51,6 +56,25 @@ public TestMethod(string name, string fullClassName, string assemblyName, bool

/// <summary>
/// Gets or sets the declaring class full name. This will be used while getting navigation data.
/// This will be null if AssemblyName is same as DeclaringAssemblyName.
/// Reason to set to null in the above case is to minimise the transfer of data across appdomains and not have a perf hit.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

this.unitTestDiscoverer.SendTestCases(source, testElements, this.mockTestCaseDiscoverySink.Object);

// Assert
this.mockTestCaseDiscoverySink.Verify(ds => ds.SendTestCase(It.Is<TestCase>(tc => VerifyTestCase(tc))), Times.Once);
Copy link
Contributor

Choose a reason for hiding this comment

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

Strange. It looks like all methods in this class seem to be validating FullyQualifiedName instead of the navigationData(line number and fileName). Changing it to that assertion would fail this test though since the mock setup is done on DummyAssembly.dll and we query navigation session on DA instead.
Its perfectly fine if we just fix this one test and I'l take an AI to fix up the rest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yeah I thought this was weird. Actually I didn't mean to leave that little VerifyTestCase method but had it for edit-and-continue convenience to find a better check. Will improve this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated test is named SendTestCasesShouldUseNaigationSessionForDeclaredAssemblyName which I think is the only SendTestCases responsibility that needs to be tested at this layer.

this.SetupTestClassAndTestMethods(isValidTestClass: true, isValidTestMethod: true, isMethodFromSameAssembly: false);
TypeEnumerator typeEnumerator = this.GetTypeEnumeratorInstance(typeof(DummyTestClass), "DummyAssemblyName");
var methodInfo = typeof(DummyTestClass).GetMethod("MethodWithVoidReturnType");
var deploymentItems = new[] { new KeyValuePair<string, string>("C:\\temp", string.Empty) };
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: This does not seem to be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch

/// <returns>Path to the .DLL of the assembly.</returns>
public string GetAssemblyPath(Assembly assembly)
{
#if NETSTANDARD1_5
Copy link
Contributor

Choose a reason for hiding this comment

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

@jayaranigarg: Do let us know if you see any concerns with this.

@AbhitejJohn
Copy link
Contributor

@ajryan : Apologies this took some time. We've been heads down with a few release activities.

@ajryan
Copy link
Contributor Author

ajryan commented May 5, 2017

Thanks for the thorough review! I'll take some time to address the issues soon.

@ajryan
Copy link
Contributor Author

ajryan commented May 14, 2017

Last changes should resolve your comments. Sorry for the slow turnaround, and thanks again for welcoming my work!

@AbhitejJohn AbhitejJohn merged commit f95b2f4 into microsoft:master May 15, 2017
@AbhitejJohn
Copy link
Contributor

No problem. Thanks again. This should just make #164 a simple flip of a switch now.

singhsarab pushed a commit to singhsarab/testfx that referenced this pull request Apr 8, 2019
…onnection problem in test host and vstest which is very large time. (microsoft#174)

Fix: Reduced it to one min
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants