Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-25533][FIXED JENKINS-19384] support for output/stdout …
…messages
  • Loading branch information
nilleb committed Mar 21, 2015
1 parent f9f5f79 commit 2b6797a
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 4 deletions.
36 changes: 34 additions & 2 deletions src/main/resources/hudson/plugins/mstest/mstest-to-junit.xsl
Expand Up @@ -45,6 +45,16 @@
<xsl:for-each select="a:Output/a:TextMessages/a:Message">
<xsl:value-of select="text()"/><xsl:text>&#10;</xsl:text>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="stdout">
<xsl:for-each select="a:Output/a:StdOut">
<xsl:value-of select="text()"/><xsl:text>&#10;</xsl:text>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="stderr">
<xsl:for-each select="a:Output/a:StdErr">
<xsl:value-of select="text()"/><xsl:text>&#10;</xsl:text>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="//a:UnitTest">
<xsl:variable name="currentExecutionId" select="a:Execution/@id"/>
Expand All @@ -67,6 +77,8 @@
<xsl:with-param name="stacktrace" select="$stacktrace"/>
<xsl:with-param name="testName" select="$testName"/>
<xsl:with-param name="textMessages" select="$textMessages"/>
<xsl:with-param name="stdout" select="$stdout"/>
<xsl:with-param name="stderr" select="$stderr"/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
Expand All @@ -86,6 +98,16 @@
<xsl:for-each select="b:Output/b:TextMessages/b:Message">
<xsl:value-of select="text()"/><xsl:text>&#10;</xsl:text>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="stdout">
<xsl:for-each select="b:Output/b:StdOut">
<xsl:value-of select="text()"/><xsl:text>&#10;</xsl:text>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="stderr">
<xsl:for-each select="b:Output/b:StdErr">
<xsl:value-of select="text()"/><xsl:text>&#10;</xsl:text>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="//b:UnitTest">
<xsl:variable name="currentTestId" select="@id"/>
Expand All @@ -108,6 +130,8 @@
<xsl:with-param name="stacktrace" select="$stacktrace"/>
<xsl:with-param name="testName" select="$testName"/>
<xsl:with-param name="textMessages" select="$textMessages"/>
<xsl:with-param name="stdout" select="$stdout"/>
<xsl:with-param name="stderr" select="$stderr"/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
Expand All @@ -124,6 +148,8 @@
<xsl:param name="message"/>
<xsl:param name="stacktrace"/>
<xsl:param name="textMessages"/>
<xsl:param name="stdout"/>
<xsl:param name="stderr"/>
<xsl:variable name="duration_seconds" select="substring($duration, 7)"/>
<xsl:variable name="duration_minutes" select="substring($duration, 4, 2 )"/>
<xsl:variable name="duration_hours" select="substring($duration, 1, 2)"/>
Expand All @@ -150,8 +176,14 @@
</xsl:if>
</xsl:element>
</xsl:if>
<xsl:if test="$textMessages != ''">
<system-out><xsl:value-of select="$textMessages"/></system-out>
<xsl:if test="$textMessages != '' or $stdout != ''">
<system-out>
<xsl:if test="$textMessages != ''"><xsl:value-of select="$textMessages"/></xsl:if>
<xsl:if test="$stdout != ''"><xsl:value-of select="$stdout"/></xsl:if>
</system-out>
</xsl:if>
<xsl:if test="$stderr != ''">
<system-err><xsl:value-of select="$stderr"/></system-err>
</xsl:if>
</testcase>
</xsl:template>
Expand Down
11 changes: 11 additions & 0 deletions src/test/java/hudson/plugins/mstest/MSTestReportConverterTest.java
Expand Up @@ -130,6 +130,17 @@ public void testIgnoredTests() throws Exception {
assertTrue("XSL transformation did not work" + myDiff, myDiff.similar());
}

@Test
public void testStdOut() throws Exception {

Transform myTransform = new Transform(
new InputSource(this.getClass().getResourceAsStream("JENKINS-25533+19384.trx")),
new InputSource(this.getClass().getResourceAsStream(MSTestReportConverter.MSTEST_TO_JUNIT_XSLFILE_STR)));

Diff myDiff = new Diff(readXmlAsString("JENKINS-25533+19384.xml"), myTransform);
assertTrue("XSL transformation did not work" + myDiff, myDiff.similar());
}

@Test
public void testConversionTestsWithDurationLongerThanOneMinute() throws Exception {

Expand Down
69 changes: 69 additions & 0 deletions src/test/resources/hudson/plugins/mstest/JENKINS-25533+19384.trx
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>

<TestRun id="8792d452-e1ff-49d8-9937-83f936f1511c" name="user@TEST_VM 2015-03-18 17:42:48" runUser="user" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<TestSettings name="Default Test Settings" id="4d40471d-767f-4aaf-a5a8-d6a4f6dca761">
<Execution>
<TestTypeSpecific />
<AgentRule name="Execution Agents">
</AgentRule>
</Execution>
<Deployment runDeploymentRoot="Jenkins_MsTest_StdOut" />
<Properties />
</TestSettings>
<Times creation="2015-03-18T17:42:48.3860256+03:00" queuing="2015-03-18T17:42:49.2503336+03:00" start="2015-03-18T17:42:49.4711568+03:00" finish="2015-03-18T17:44:09.3160066+03:00" />
<ResultSummary outcome="Failed">
<Counters total="4" executed="4" error="0" failed="4" timeout="0" aborted="0" inconclusive="0" passedButRunAborted="0" notRunnable="0" notExecuted="0" disconnected="0" warning="0" passed="0" completed="0" inProgress="0" pending="0" />
</ResultSummary>
<TestDefinitions>
<OrderedTest name="RouteOptimization_SanityCheck" storage="c:\autotester\bin\routeoptimization_sanitycheck.orderedtest" id="082fabc9-d9e5-4339-9787-a8a6e3886f9b" continueAfterFailure="true">
<Execution id="b6a601f4-8e48-4abf-8823-97a29a629efd" />
<TestLinks>
<TestLink id="a94138fa-750a-4f8a-4d1e-e4b9d6f37fa0" name="Login" storage="bin\debug\TestAutomation.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</TestLinks>
</OrderedTest>
<UnitTest name="Login" storage="c:\TestAutomation.dll" id="a94138fa-750a-4f8a-4d1e-e4b9d6f37fa0">
<TestMethod codeBase="c:/autotester/bin/TestAutomation.dll" adapterTypeName="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Adapter, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" className="UITestAutomation.RouteOptimization_SanityCheck, TestAutomation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="Login" />
</UnitTest>
</TestDefinitions>
<TestLists>
<TestList name="Results Not in a List" id="8c84fa94-04c1-424b-9868-57a2d4851a1d" />
<TestList name="All Loaded Results" id="19431567-8539-422a-85d7-44ee4e166bda" />
</TestLists>
<TestEntries>
<TestEntry testId="082fabc9-d9e5-4339-9787-a8a6e3886f9b" executionId="b6a601f4-8e48-4abf-8823-97a29a629efd" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d">
<TestEntries>
<TestEntry testId="a94138fa-750a-4f8a-4d1e-e4b9d6f37fa0" executionId="25041167-b2d2-412f-862f-190bdf974170" parentExecutionId="b6a601f4-8e48-4abf-8823-97a29a629efd" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" />
</TestEntries>
</TestEntry>
</TestEntries>
<Results>
<TestResultAggregation executionId="b6a601f4-8e48-4abf-8823-97a29a629efd" testId="082fabc9-d9e5-4339-9787-a8a6e3886f9b" testName="SanityCheck" computerName="TEST_VM" duration="00:01:09.5895342" startTime="2015-03-18T17:42:49.5560888+03:00" endTime="2015-03-18T17:43:59.1260450+03:00" testType="ec4800e8-40e5-4ab3-8510-b8bf29b1904d" outcome="Failed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="b6a601f4-8e48-4abf-8823-97a29a629efd">
<Counters error="0" failed="3" timeout="0" aborted="0" inconclusive="0" passedButRunAborted="0" notRunnable="0" notExecuted="0" disconnected="0" warning="0" passed="0" completed="0" inProgress="0" pending="0" />
<InnerResults>
<UnitTestResult executionId="25041167-b2d2-412f-862f-190bdf974170" parentExecutionId="b6a601f4-8e48-4abf-8823-97a29a629efd" testId="a94138fa-750a-4f8a-4d1e-e4b9d6f37fa0" testName="Login" computerName="TEST_VM" duration="00:00:43.8338627" startTime="2015-03-18T17:42:49.5760728+03:00" endTime="2015-03-18T17:43:34.2210270+03:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Failed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="25041167-b2d2-412f-862f-190bdf974170">
<Output>
<StdOut>17:43:23 ..Failed to connect: Attempt 0
17:43:25 ..Connected to CLIENT : v1.0.511.0
17:43:25 [PASS] Check Login dialog is presented on the main page
17:43:25 [PASS] Check OK button is disabled on initial Login Screen
17:43:27 ..Entered user name
17:43:28 ..Enter user password
17:43:28 [PASS] Check OK button became enabled after entered credentials
17:43:29 ..Confirmed login by OK button press</StdOut>
<ErrorInfo>
<Message>Test method SanityCheck.Login threw exception:
ArtOfTest.Common.Exceptions.AssertException: Assert.AreEqual - [Expected:True],[Actual:False]</Message>
<StackTrace> at ArtOfTest.Common.UnitTesting.Assert.AreEqual[T](T expected, T actual, String message)
at ArtOfTest.Common.UnitTesting.Assert.AreEqual[T](T expected, T actual)
at UITestAutomation.SimpleChecks.IsLoginDialogShown() in d:\tests_Workspace\src\TestAutomation\TestActions.cs:line 455
at UITestAutomation.SimpleChecks.CheckLoginDialogShown(Boolean exp, String msg) in d:\tests_Workspace\src\TestAutomation\TestActions.cs:line 425
at UITestAutomation.SimpleActions.LoginAs(String user, String password) in d:\tests_Workspace\src\TestAutomation\TestActions.cs:line 76
at SanityCheck.Login() in d:\tests_Workspace\src\TestAutomation\SanityCheck.cs:line 25
</StackTrace>
</ErrorInfo>
</Output>
</UnitTestResult>
</InnerResults>
</TestResultAggregation>
</Results>
</TestRun>
22 changes: 22 additions & 0 deletions src/test/resources/hudson/plugins/mstest/JENKINS-25533+19384.xml
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?><testsuites xmlns:b="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" xmlns:a="http://microsoft.com/schemas/VisualStudio/TeamTest/2006">
<testsuite name="MSTestSuite" tests="4" time="0" failures="4" errors="0" skipped="0">
<testcase classname="UITestAutomation.RouteOptimization_SanityCheck" name="Login" time="43.8338627">
<failure message="Test method SanityCheck.Login threw exception: &#10;ArtOfTest.Common.Exceptions.AssertException: Assert.AreEqual - [Expected:True],[Actual:False]"> at ArtOfTest.Common.UnitTesting.Assert.AreEqual[T](T expected, T actual, String message)
at ArtOfTest.Common.UnitTesting.Assert.AreEqual[T](T expected, T actual)
at UITestAutomation.SimpleChecks.IsLoginDialogShown() in d:\tests_Workspace\src\TestAutomation\TestActions.cs:line 455
at UITestAutomation.SimpleChecks.CheckLoginDialogShown(Boolean exp, String msg) in d:\tests_Workspace\src\TestAutomation\TestActions.cs:line 425
at UITestAutomation.SimpleActions.LoginAs(String user, String password) in d:\tests_Workspace\src\TestAutomation\TestActions.cs:line 76
at SanityCheck.Login() in d:\tests_Workspace\src\TestAutomation\SanityCheck.cs:line 25
</failure>
<system-out>17:43:23 ..Failed to connect: Attempt 0
17:43:25 ..Connected to CLIENT : v1.0.511.0
17:43:25 [PASS] Check Login dialog is presented on the main page
17:43:25 [PASS] Check OK button is disabled on initial Login Screen
17:43:27 ..Entered user name
17:43:28 ..Enter user password
17:43:28 [PASS] Check OK button became enabled after entered credentials
17:43:29 ..Confirmed login by OK button press
</system-out>
</testcase>
</testsuite>
</testsuites>
Expand Up @@ -11,7 +11,15 @@
<testcase classname="green.Tests.greenTest" name="args_protect_from_dos_interpretation" time="0.066633"/>
<testcase classname="green.Tests.greenTest" name="args_protect_from_dos_interpretation_nn" time="0.0001573"/>
<testcase classname="green.Tests.DepGetRestoreTest" name="repositories" time="5.7780042"/>
<testcase classname="green.Tests.DepGetTest" name="hardcoded_source" time="4.0947049"/>
<testcase classname="green.Tests.DepGetTest" name="hardcoded_source" time="4.0947049">
<system-out>depget: installing depget.0.5.1
* the package 'depget version 0.5.1' has been downloaded.
- copying the folder 'content' to cwd
depget: installing Cegid.MsiMake.8.0.6
* the package 'Cegid.MsiMake version 8.0.6' has been downloaded.
- copying the folder 'content' to cwd
</system-out>
</testcase>
<testcase classname="green.Tests.DepGetTest" name="source_cant_be_resolved_against_local_nuget_config" time="0.0021988"/>
<testcase classname="green.Tests.ComposeItemGroupTest" name="listOfItems" time="0.0052196"/>
<testcase classname="green.Tests.ComposeItemGroupTest" name="listOfItems_globs" time="0.0016981"/>
Expand All @@ -21,4 +29,4 @@
<testcase classname="green.Tests.ReadAssemblyVersionInfoTaskTest" name="cs" time="0.0004587"/>
<testcase classname="green.Tests.ReadAssemblyVersionInfoTaskTest" name="vb" time="0.0004777"/>
</testsuite>
</testsuites>
</testsuites>

1 comment on commit 2b6797a

@daniel-beck
Copy link
Member

Choose a reason for hiding this comment

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

Looks like you got the wrong issue ID:
https://issues.jenkins-ci.org/browse/JENKINS-25533

Please sign in to comment.