-
Notifications
You must be signed in to change notification settings - Fork 266
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
Changes from 8 commits
28ab3bc
4f71d7c
7829b45
a783992
311a492
1da1628
fb92014
6925245
74b8768
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add/modify some existing tests to cover this as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
unitTestResult.ParentExecId = testResults[i].ParentExecId; | ||
unitTestResult.InnerResultsCount = testResults[i].InnerResultsCount; | ||
unitTestResults[i] = unitTestResult; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch 👍 |
||
var unitTestOutcome2 = outcome2.ToUnitTestOutcome(); | ||
return unitTestOutcome1 < unitTestOutcome2 ? outcome1 : outcome2; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,21 @@ internal UnitTestResult(UnitTestOutcome outcome, string errorMessage) | |
/// </summary> | ||
public string ErrorStackTrace { get; internal set; } | ||
|
||
/// <summary> | ||
/// Gets the execution id of the result | ||
/// </summary> | ||
public Guid ExecutionId { get; internal set; } | ||
|
||
/// <summary> | ||
/// Gets the parent execution id of the result | ||
/// </summary> | ||
public Guid ParentExecId { get; internal set; } | ||
|
||
/// <summary> | ||
/// Gets the inner results count of the result | ||
/// </summary> | ||
public int InnerResultsCount { get; internal set; } | ||
|
||
/// <summary> | ||
/// Gets the duration of the result | ||
/// </summary> | ||
|
@@ -149,6 +164,10 @@ internal TestResult ToTestResult(TestCase testCase, DateTimeOffset startTime, Da | |
EndTime = endTime | ||
}; | ||
|
||
testResult.SetPropertyValue<Guid>(Constants.ExecutionIdProperty, this.ExecutionId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar for this. Add/modify existing tests to cover this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. |
||
testResult.SetPropertyValue<Guid>(Constants.ParentExecIdProperty, this.ParentExecId); | ||
testResult.SetPropertyValue<int>(Constants.InnerResultsCountProperty, this.InnerResultsCount); | ||
|
||
if (!string.IsNullOrEmpty(this.StandardOut)) | ||
{ | ||
TestResultMessage message = new TestResultMessage(TestResultMessage.StandardOutCategory, this.StandardOut); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,10 @@ public void ExecuteCustomTestExtensibilityWithTestDataTests() | |
"CustomTestMethod2 (B)", | ||
"CustomTestMethod2 (B)", | ||
"CustomTestMethod2 (B)"); | ||
this.ValidateFailedTests( | ||
|
||
// Parent results should fail and thus failed count should be 7. | ||
this.ValidateFailedTestsCount(7); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did we add this? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
this.ValidateFailedTestsContain( | ||
TestAssembly, | ||
"CustomTestMethod2 (A)", | ||
"CustomTestMethod2 (A)", | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.