From c49b01c23d6b32a8a890b6441161c7d3d53e4612 Mon Sep 17 00:00:00 2001 From: Tanvi Soni Date: Mon, 22 Aug 2016 13:11:50 +0530 Subject: [PATCH 1/6] support pending outcome in trx --- src/Agent.Worker/TestResults/TrxResultReader.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Agent.Worker/TestResults/TrxResultReader.cs b/src/Agent.Worker/TestResults/TrxResultReader.cs index 1758ced921..3755b8c9e3 100644 --- a/src/Agent.Worker/TestResults/TrxResultReader.cs +++ b/src/Agent.Worker/TestResults/TrxResultReader.cs @@ -286,14 +286,18 @@ private List ReadActualResults(XmlNodeList resultsNodes, str DateTime completedDate = startedDate.AddTicks(duration.Ticks); resultCreateModel.CompletedDate = completedDate; - if (resultNode.Attributes["outcome"] != null && resultNode.Attributes["outcome"].Value != null) + if (resultNode.Attributes["outcome"] == null || resultNode.Attributes["outcome"].Value == null) + { + resultCreateModel.Outcome = "Failed"; + } + else if (string.Equals(resultNode.Attributes["outcome"].Value, "passed", StringComparison.OrdinalIgnoreCase) || string.Equals(resultNode.Attributes["outcome"].Value, "failed", StringComparison.OrdinalIgnoreCase)) { resultCreateModel.Outcome = resultNode.Attributes["outcome"].Value; } else - { - resultCreateModel.Outcome = "Failed"; - } + { + resultCreateModel.Outcome = TestOutcome.NotExecuted.ToString(); + } if (resultNode.Attributes["testName"] != null && resultNode.Attributes["testName"].Value != null) { From f2c7a0b6d5e71cd11b291d868698bcec5e8f813b Mon Sep 17 00:00:00 2001 From: Tanvi Soni Date: Tue, 23 Aug 2016 18:50:25 +0530 Subject: [PATCH 2/6] adding test --- .../TestResults/TrxResultReaderTests.cs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/Test/L0/Worker/TestResults/TrxResultReaderTests.cs b/src/Test/L0/Worker/TestResults/TrxResultReaderTests.cs index 413dbd6f71..061eda0260 100644 --- a/src/Test/L0/Worker/TestResults/TrxResultReaderTests.cs +++ b/src/Test/L0/Worker/TestResults/TrxResultReaderTests.cs @@ -46,6 +46,49 @@ public void ResultsWithoutTestNamesAreSkipped() Assert.Equal(0, runData.Results.Length); } + [Fact] + [Trait("Level", "L0")] + [Trait("Category", "PublishTestResults")] + public void PendingOutcomeTreatedAsNotExecuted() + { + SetupMocks(); + String trxContents = "" + + "" + + + "" + + "" + + "" + + "" + + + "" + + "Show console log output.Assert.Fail failed.at UnitTestProject4.UnitTest1.TestMethod2() in C:\\Users\\somerandomusername\\Source\\Repos\\Projectx\\UnitTestProject4\\UnitTestProject4\\UnitTest1.cs:line 21" + + "" + + "" + + + "Do not show console log output." + + "" + + "" + + "" + + "LOCAL SERVICE_LAB-BUILDVNEXT 2015-05-20 18_53_41\\In\\eb421c16-4546-435a-9c24-0d2878ea76d4\\PSD_Startseite.webtestResult" + + "" + + "" + + + "" + + "" + + + ""; + + var runData = GetTestRunData(trxContents, null, new TestRunContext("Owner", "any cpu", "debug", 1, "", "releaseUri", "releaseEnvironmentUri")); + + Assert.Equal(runData.Results.Length, 2); + + Assert.Equal(runData.Results[0].Outcome, "Failed"); + Assert.Equal(runData.Results[0].TestCaseTitle, "TestMethod2"); + + Assert.Equal(runData.Results[1].Outcome, "Passed"); + Assert.Equal(runData.Results[1].TestCaseTitle, "PSD_Startseite"); + } + [Fact] [Trait("Level", "L0")] [Trait("Category", "PublishTestResults")] From f52ddeaf5edf5c94ac39168472e959ede2e65341 Mon Sep 17 00:00:00 2001 From: Tanvi Soni Date: Tue, 23 Aug 2016 19:12:41 +0530 Subject: [PATCH 3/6] pending treated as not executed --- src/Test/L0/Worker/TestResults/TrxResultReaderTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Test/L0/Worker/TestResults/TrxResultReaderTests.cs b/src/Test/L0/Worker/TestResults/TrxResultReaderTests.cs index 061eda0260..f450644a3a 100644 --- a/src/Test/L0/Worker/TestResults/TrxResultReaderTests.cs +++ b/src/Test/L0/Worker/TestResults/TrxResultReaderTests.cs @@ -61,7 +61,7 @@ public void PendingOutcomeTreatedAsNotExecuted() "" + "" + - "Show console log output.Assert.Fail failed.at UnitTestProject4.UnitTest1.TestMethod2() in C:\\Users\\somerandomusername\\Source\\Repos\\Projectx\\UnitTestProject4\\UnitTestProject4\\UnitTest1.cs:line 21" + + "Show console log output.Assert.Fail failed.at UnitTestProject4.UnitTest1.TestMethod2() in C:\\Users\\somerandomusername\\Source\\Repos\\Projectx\\UnitTestProject4\\UnitTestProject4\\UnitTest1.cs:line 21" + "" + "" + @@ -82,7 +82,7 @@ public void PendingOutcomeTreatedAsNotExecuted() Assert.Equal(runData.Results.Length, 2); - Assert.Equal(runData.Results[0].Outcome, "Failed"); + Assert.Equal(runData.Results[0].Outcome, "Pending"); Assert.Equal(runData.Results[0].TestCaseTitle, "TestMethod2"); Assert.Equal(runData.Results[1].Outcome, "Passed"); From e29232ef27bcfd71d59cd6236661f6576ff4a673 Mon Sep 17 00:00:00 2001 From: Tanvi Soni Date: Tue, 23 Aug 2016 19:13:51 +0530 Subject: [PATCH 4/6] changing outcome --- src/Test/L0/Worker/TestResults/TrxResultReaderTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Test/L0/Worker/TestResults/TrxResultReaderTests.cs b/src/Test/L0/Worker/TestResults/TrxResultReaderTests.cs index f450644a3a..f12d4b2853 100644 --- a/src/Test/L0/Worker/TestResults/TrxResultReaderTests.cs +++ b/src/Test/L0/Worker/TestResults/TrxResultReaderTests.cs @@ -82,7 +82,7 @@ public void PendingOutcomeTreatedAsNotExecuted() Assert.Equal(runData.Results.Length, 2); - Assert.Equal(runData.Results[0].Outcome, "Pending"); + Assert.Equal(runData.Results[0].Outcome, "NotExecuted"); Assert.Equal(runData.Results[0].TestCaseTitle, "TestMethod2"); Assert.Equal(runData.Results[1].Outcome, "Passed"); From bd334bf5454accab0b45034821ca7c11c21dcb24 Mon Sep 17 00:00:00 2001 From: Tanvi Soni Date: Tue, 23 Aug 2016 22:26:56 +0530 Subject: [PATCH 5/6] cr comment --- src/Agent.Worker/TestResults/TrxResultReader.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Agent.Worker/TestResults/TrxResultReader.cs b/src/Agent.Worker/TestResults/TrxResultReader.cs index 3755b8c9e3..382406ebfa 100644 --- a/src/Agent.Worker/TestResults/TrxResultReader.cs +++ b/src/Agent.Worker/TestResults/TrxResultReader.cs @@ -286,13 +286,13 @@ private List ReadActualResults(XmlNodeList resultsNodes, str DateTime completedDate = startedDate.AddTicks(duration.Ticks); resultCreateModel.CompletedDate = completedDate; - if (resultNode.Attributes["outcome"] == null || resultNode.Attributes["outcome"].Value == null) + if (resultNode.Attributes["outcome"] == null || resultNode.Attributes["outcome"].Value == null || string.Equals(resultNode.Attributes["outcome"].Value, "failed", StringComparison.OrdinalIgnoreCase)) { - resultCreateModel.Outcome = "Failed"; + resultCreateModel.Outcome = TestOutcome.Failed.ToString(); ; } - else if (string.Equals(resultNode.Attributes["outcome"].Value, "passed", StringComparison.OrdinalIgnoreCase) || string.Equals(resultNode.Attributes["outcome"].Value, "failed", StringComparison.OrdinalIgnoreCase)) + else if (string.Equals(resultNode.Attributes["outcome"].Value, "passed", StringComparison.OrdinalIgnoreCase)) { - resultCreateModel.Outcome = resultNode.Attributes["outcome"].Value; + resultCreateModel.Outcome = TestOutcome.Passed.ToString(); } else { From 57ade06c68852ba36bfe048083371d015f5646f1 Mon Sep 17 00:00:00 2001 From: Tanvi Soni Date: Tue, 23 Aug 2016 22:29:32 +0530 Subject: [PATCH 6/6] removing empty lines --- src/Test/L0/Worker/TestResults/TrxResultReaderTests.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Test/L0/Worker/TestResults/TrxResultReaderTests.cs b/src/Test/L0/Worker/TestResults/TrxResultReaderTests.cs index f12d4b2853..dc04893bb1 100644 --- a/src/Test/L0/Worker/TestResults/TrxResultReaderTests.cs +++ b/src/Test/L0/Worker/TestResults/TrxResultReaderTests.cs @@ -54,17 +54,15 @@ public void PendingOutcomeTreatedAsNotExecuted() SetupMocks(); String trxContents = "" + "" + - "" + "" + "" + - "" + - + "" + + "" + "Show console log output.Assert.Fail failed.at UnitTestProject4.UnitTest1.TestMethod2() in C:\\Users\\somerandomusername\\Source\\Repos\\Projectx\\UnitTestProject4\\UnitTestProject4\\UnitTest1.cs:line 21" + "" + "" + - "Do not show console log output." + "" + "" + @@ -75,7 +73,6 @@ public void PendingOutcomeTreatedAsNotExecuted() "" + "" + - ""; var runData = GetTestRunData(trxContents, null, new TestRunContext("Owner", "any cpu", "debug", 1, "", "releaseUri", "releaseEnvironmentUri")); @@ -84,7 +81,6 @@ public void PendingOutcomeTreatedAsNotExecuted() Assert.Equal(runData.Results[0].Outcome, "NotExecuted"); Assert.Equal(runData.Results[0].TestCaseTitle, "TestMethod2"); - Assert.Equal(runData.Results[1].Outcome, "Passed"); Assert.Equal(runData.Results[1].TestCaseTitle, "PSD_Startseite"); }