Skip to content

Commit 904a0f3

Browse files
authored
Merge pull request #521 from Microsoft/users/tasoni/supportPendingOutcome
support pending outcome in trx
2 parents b5ff725 + 57ade06 commit 904a0f3

File tree

2 files changed

+48
-5
lines changed

2 files changed

+48
-5
lines changed

src/Agent.Worker/TestResults/TrxResultReader.cs

+9-5
Original file line numberDiff line numberDiff line change
@@ -286,14 +286,18 @@ private List<TestCaseResultData> ReadActualResults(XmlNodeList resultsNodes, str
286286
DateTime completedDate = startedDate.AddTicks(duration.Ticks);
287287
resultCreateModel.CompletedDate = completedDate;
288288

289-
if (resultNode.Attributes["outcome"] != null && resultNode.Attributes["outcome"].Value != null)
289+
if (resultNode.Attributes["outcome"] == null || resultNode.Attributes["outcome"].Value == null || string.Equals(resultNode.Attributes["outcome"].Value, "failed", StringComparison.OrdinalIgnoreCase))
290290
{
291-
resultCreateModel.Outcome = resultNode.Attributes["outcome"].Value;
292-
}
293-
else
291+
resultCreateModel.Outcome = TestOutcome.Failed.ToString(); ;
292+
}
293+
else if (string.Equals(resultNode.Attributes["outcome"].Value, "passed", StringComparison.OrdinalIgnoreCase))
294294
{
295-
resultCreateModel.Outcome = "Failed";
295+
resultCreateModel.Outcome = TestOutcome.Passed.ToString();
296296
}
297+
else
298+
{
299+
resultCreateModel.Outcome = TestOutcome.NotExecuted.ToString();
300+
}
297301

298302
if (resultNode.Attributes["testName"] != null && resultNode.Attributes["testName"].Value != null)
299303
{

src/Test/L0/Worker/TestResults/TrxResultReaderTests.cs

+39
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,45 @@ public void ResultsWithoutTestNamesAreSkipped()
4646
Assert.Equal(0, runData.Results.Length);
4747
}
4848

49+
[Fact]
50+
[Trait("Level", "L0")]
51+
[Trait("Category", "PublishTestResults")]
52+
public void PendingOutcomeTreatedAsNotExecuted()
53+
{
54+
SetupMocks();
55+
String trxContents = "<?xml version = \"1.0\" encoding = \"UTF-8\"?>" +
56+
"<TestRun id = \"ee3d8b3b-1ac9-4a7e-abfa-3d3ed2008613\" name = \"somerandomusername@SOMERANDOMCOMPUTERNAME 2015-03-20 16:53:32\" runUser = \"FAREAST\\somerandomusername\" xmlns =\"http://microsoft.com/schemas/VisualStudio/TeamTest/2010\"><Times creation = \"2015-03-20T16:53:32.3309380+05:30\" queuing = \"2015-03-20T16:53:32.3319381+05:30\" start = \"2015-03-20T16:53:32.3349628+05:30\" finish = \"2015-03-20T16:53:32.9232329+05:30\" />" +
57+
"<TestDefinitions>" +
58+
"<UnitTest name = \"TestMethod2\" storage = \"c:/users/somerandomusername/source/repos/projectx/unittestproject4/unittestproject4/bin/debug/unittestproject4.dll\" priority = \"1\" id = \"f0d6b58f-dc08-9c0b-aab7-0a1411d4a346\"><Owners><Owner name = \"asdf2\" /></Owners><Execution id = \"48ec1e47-b9df-43b9-aef2-a2cc8742353d\" /><TestMethod codeBase = \"c:/users/somerandomusername/source/repos/projectx/unittestproject4/unittestproject4/bin/debug/unittestproject4.dll\" adapterTypeName = \"Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter\" className = \"UnitTestProject4.UnitTest1\" name = \"TestMethod2\" /></UnitTest>" +
59+
"<WebTest name=\"PSD_Startseite\" storage=\"c:\\vsoagent\\a284d2cc\\vseqa1\\psd_startseite.webtest\" id=\"01da1a13-b160-4ee6-9d84-7a6dfe37b1d2\" persistedWebTest=\"7\"><TestCategory><TestCategoryItem TestCategory=\"PSD\" /></TestCategory><Execution id=\"eb421c16-4546-435a-9c24-0d2878ea76d4\" /></WebTest>" +
60+
"</TestDefinitions>" +
61+
62+
"<Results>" +
63+
"<UnitTestResult executionId = \"48ec1e47-b9df-43b9-aef2-a2cc8742353d\" testId = \"f0d6b58f-dc08-9c0b-aab7-0a1411d4a346\" testName = \"TestMethod2\" computerName = \"SOMERANDOMCOMPUTERNAME\" duration = \"00:00:00.0834563\" startTime = \"2015-03-20T16:53:32.3099353+05:30\" endTime = \"2015-03-20T16:53:32.3939623+05:30\" testType = \"13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b\" outcome = \"Pending\" testListId = \"8c84fa94-04c1-424b-9868-57a2d4851a1d\" relativeResultsDirectory = \"48ec1e47-b9df-43b9-aef2-a2cc8742353d\" ><Output><StdOut>Show console log output.</StdOut><ErrorInfo><Message>Assert.Fail failed.</Message><StackTrace>at UnitTestProject4.UnitTest1.TestMethod2() in C:\\Users\\somerandomusername\\Source\\Repos\\Projectx\\UnitTestProject4\\UnitTestProject4\\UnitTest1.cs:line 21</StackTrace></ErrorInfo></Output>" +
64+
"<ResultFiles><ResultFile path=\"DIGANR-DEV4\\x.txt\" /></ResultFiles>" +
65+
"</UnitTestResult>" +
66+
"<WebTestResult executionId=\"eb421c16-4546-435a-9c24-0d2878ea76d4\" testId=\"01da1a13-b160-4ee6-9d84-7a6dfe37b1d2\" testName=\"PSD_Startseite\" computerName=\"LAB-BUILDVNEXT\" duration=\"00:00:01.6887389\" startTime=\"2015-05-20T18:53:51.1063165+00:00\" endTime=\"2015-05-20T18:54:03.9160742+00:00\" testType=\"4e7599fa-5ecb-43e9-a887-cd63cf72d207\" outcome=\"Passed\" testListId=\"8c84fa94-04c1-424b-9868-57a2d4851a1d\" relativeResultsDirectory=\"eb421c16-4546-435a-9c24-0d2878ea76d4\"><Output><StdOut>Do not show console log output.</StdOut></Output>" +
67+
"<ResultFiles>" +
68+
"<ResultFile path=\"PSD_Startseite.webtestResult\" />" +
69+
"</ResultFiles>" +
70+
"<WebTestResultFilePath>LOCAL SERVICE_LAB-BUILDVNEXT 2015-05-20 18_53_41\\In\\eb421c16-4546-435a-9c24-0d2878ea76d4\\PSD_Startseite.webtestResult</WebTestResultFilePath>" +
71+
"</WebTestResult>" +
72+
"</Results>" +
73+
74+
"<ResultSummary outcome=\"Failed\"><Counters total = \"2\" executed = \"2\" passed=\"1\" failed=\"1\" error=\"0\" timeout=\"0\" aborted=\"0\" inconclusive=\"0\" passedButRunAborted=\"0\" notRunnable=\"0\" notExecuted=\"0\" disconnected=\"0\" warning=\"0\" completed=\"0\" inProgress=\"0\" pending=\"0\" />" +
75+
"</ResultSummary>" +
76+
"</TestRun>";
77+
78+
var runData = GetTestRunData(trxContents, null, new TestRunContext("Owner", "any cpu", "debug", 1, "", "releaseUri", "releaseEnvironmentUri"));
79+
80+
Assert.Equal(runData.Results.Length, 2);
81+
82+
Assert.Equal(runData.Results[0].Outcome, "NotExecuted");
83+
Assert.Equal(runData.Results[0].TestCaseTitle, "TestMethod2");
84+
Assert.Equal(runData.Results[1].Outcome, "Passed");
85+
Assert.Equal(runData.Results[1].TestCaseTitle, "PSD_Startseite");
86+
}
87+
4988
[Fact]
5089
[Trait("Level", "L0")]
5190
[Trait("Category", "PublishTestResults")]

0 commit comments

Comments
 (0)