Skip to content

Parent test result support for data driven tests#417

Merged
abhishkk merged 9 commits into
microsoft:masterfrom
abhishkk:adapterHierarchical
Jun 5, 2018
Merged

Parent test result support for data driven tests#417
abhishkk merged 9 commits into
microsoft:masterfrom
abhishkk:adapterHierarchical

Conversation

@abhishkk

@abhishkk abhishkk commented May 8, 2018

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

unitTestResult.DisplayName = testResults[i].DisplayName;
unitTestResult.DatarowIndex = testResults[i].DatarowIndex;
unitTestResult.ResultFiles = testResults[i].ResultFiles;
unitTestResult.ExecutionId = testResults[i].ExecutionId;

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

EndTime = endTime
};

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

Copy link
Copy Markdown
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
Copy Markdown
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);

@jayaranigarg jayaranigarg May 9, 2018

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
Member

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

internal static UTF.UnitTestOutcome GetMoreImportantOutcome(this UTF.UnitTestOutcome outcome1, UTF.UnitTestOutcome outcome2)
{
return outcome1 < outcome2 ? outcome1 : outcome2;
var unitTestOutcome1 = outcome1.ToUnitTestOutcome();

Copy link
Copy Markdown
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
Copy Markdown
Member

@abhishkk : Please push this in soon.

@abhishkk

abhishkk commented Jun 5, 2018

Copy link
Copy Markdown
Contributor Author

RFC is not required for this. So skipping.

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

Elyseum commented Jul 20, 2018

Copy link
Copy Markdown

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
Copy Markdown
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

Elyseum commented Jul 20, 2018

Copy link
Copy Markdown

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