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

Parent test result support for data driven tests #417

Merged
merged 9 commits into from
Jun 5, 2018

Conversation

abhishkk
Copy link
Contributor

@abhishkk abhishkk commented May 8, 2018

Mstest v2 adapter changes:

  1. Created parent test result for mstest v1 data driven tests
  2. passing execution id and parent exeuction id to test platform via test result’s properties.

Copy from PR #342

@abhishkk abhishkk requested a review from jayaranigarg May 8, 2018 07:18
var aggregateOutcome = results[0].Outcome;
foreach (var result in results)
{
UnitTestOutcomeExtensions.GetMoreImportantOutcome(aggregateOutcome, result.Outcome);
Copy link
Member

Choose a reason for hiding this comment

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

We don't need to assign result of GetMoreImportantOutcome() back to aggregateOutcome?

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. UTs caught this and were failing. Corrected.

private UTF.UnitTestOutcome GetAggregateOutcome(List<UTF.TestResult> results)
{
// In case results are not present, set outcome as unknown.
if (!results.Any())
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: results.Count==0 seems more readable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In case of list, using Count or Any doesn't matter. But in case of Enumerable any is preferred over count as count iterates through entire list. Thus as a general practice, for both list and enumerable I prefer any.

this.ValidateFailedTests(

// Parent results should fail and thus failed count should be 7.
this.ValidateFailedTestsCount(7);
Copy link
Member

Choose a reason for hiding this comment

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

Why did we add this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ValidateFailedTests method checks for number of tests. Number of params passed to the methods are considered as numbers of tests. In our case, we dont want to pass parent results as param but still want to consider it for results length check. Thus checking the count of tests separately.

@@ -47,6 +47,9 @@ public static UnitTestResult[] ToUnitTestResults(this UTF.TestResult[] testResul
unitTestResult.DisplayName = testResults[i].DisplayName;
unitTestResult.DatarowIndex = testResults[i].DatarowIndex;
unitTestResult.ResultFiles = testResults[i].ResultFiles;
unitTestResult.ExecutionId = testResults[i].ExecutionId;
Copy link
Member

Choose a reason for hiding this comment

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

Add/modify some existing tests to cover this as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -149,6 +164,10 @@ internal TestResult ToTestResult(TestCase testCase, DateTimeOffset startTime, Da
EndTime = endTime
};

testResult.SetPropertyValue<Guid>(Constants.ExecutionIdProperty, this.ExecutionId);
Copy link
Member

Choose a reason for hiding this comment

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

Similar for this. Add/modify existing tests to cover this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@@ -429,9 +429,11 @@ public void RunTestMethodForMultipleResultsReturnMultipleResults()
var testMethodRunner = new TestMethodRunner(testMethodInfo, this.testMethod, this.testContextImplementation, false);
Copy link
Member

@jayaranigarg jayaranigarg May 9, 2018

Choose a reason for hiding this comment

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

There are a bunch of data-driven tests in this class. Please make sure they are validating correct things even though they are not failing. Ideally they should have failed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Various data driven tests were failing. We have fixed them in the PR.

@jayaranigarg
Copy link
Member

Add a RFC for this change and link RFC to this PR.

@@ -61,7 +61,9 @@ public static UnitTestOutcome ToUnitTestOutcome(this UTF.UnitTestOutcome framewo
/// <returns> Outcome which has higher importance.</returns>
internal static UTF.UnitTestOutcome GetMoreImportantOutcome(this UTF.UnitTestOutcome outcome1, UTF.UnitTestOutcome outcome2)
{
return outcome1 < outcome2 ? outcome1 : outcome2;
var unitTestOutcome1 = outcome1.ToUnitTestOutcome();
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch 👍

@jayaranigarg
Copy link
Member

@abhishkk : Please push this in soon.

@abhishkk
Copy link
Contributor Author

abhishkk commented Jun 5, 2018

RFC is not required for this. So skipping.

@abhishkk abhishkk merged commit e13ca08 into microsoft:master Jun 5, 2018
@Elyseum
Copy link

Elyseum commented Jul 20, 2018

This change should have been an opt-in / configurable because it breaks existing flows. For example, Visual Studio Online doesn't support displaying child tests (yet). So atm, if a child test fails, you only see the parent failing in the UI and there is now way (as far as I'm aware of) to get hold of the test attachments of the failing child.

@abhishkk
Copy link
Contributor Author

@Elyseum

Visual Studio Online doesn't support displaying child tests (yet).

Support is enabled in visual studio online (vsts). You can use vstest v2 task along with

  1. VS version >= 15.8 preview 4, or Using tools installer package.
  2. Latest MSTest adapter version

So atm, if a child test fails, you only see the parent failing in the UI and there is now way (as far as I'm aware of) to get hold of the test attachments of the failing child.

The behavior of vstest v2 task was different for single agent and multi agent flows. For single agent, all child results were shown but for multi agent, only one result was shown. These changes not only enable hierarchical support but brings consistency in behavior of single and multi agent flows. Now in both cases, parent and child results are shown (where child results are in hierarchical form)

@Elyseum
Copy link

Elyseum commented Jul 20, 2018

We don't have VS version >= 15.8 preview 4 yet, so that might be our issue. My mistake then :). Thank you for the detailed update.

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.

3 participants