Skip to content

Commit

Permalink
[FIXED JENKINS-17506] support for TextMessages (standard output of ms…
Browse files Browse the repository at this point in the history
…test unit tests)
  • Loading branch information
nilleb committed Mar 13, 2015
1 parent 22100ec commit cee1fee
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/main/resources/hudson/plugins/mstest/mstest-to-junit.xsl
Expand Up @@ -33,6 +33,11 @@
<xsl:variable name="outcome" select="@outcome"/>
<xsl:variable name="message" select="a:Output/a:ErrorInfo/a:Message"/>
<xsl:variable name="stacktrace" select="a:Output/a:ErrorInfo/a:StackTrace"/>
<xsl:variable name="textMessages">
<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:for-each select="//a:UnitTest">
<xsl:variable name="currentExecutionId" select="a:Execution/@id"/>
<xsl:if test="$currentExecutionId = $executionId" >
Expand All @@ -53,6 +58,7 @@
<xsl:with-param name="outcome" select="$outcome"/>
<xsl:with-param name="stacktrace" select="$stacktrace"/>
<xsl:with-param name="testName" select="$testName"/>
<xsl:with-param name="textMessages" select="$textMessages"/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
Expand All @@ -68,6 +74,11 @@
<xsl:variable name="outcome" select="@outcome"/>
<xsl:variable name="message" select="b:Output/b:ErrorInfo/b:Message"/>
<xsl:variable name="stacktrace" select="b:Output/b:ErrorInfo/b:StackTrace"/>
<xsl:variable name="textMessages">
<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:for-each select="//b:UnitTest">
<xsl:variable name="currentTestId" select="@id"/>
<xsl:if test="$currentTestId = $testId" >
Expand All @@ -88,6 +99,7 @@
<xsl:with-param name="outcome" select="$outcome"/>
<xsl:with-param name="stacktrace" select="$stacktrace"/>
<xsl:with-param name="testName" select="$testName"/>
<xsl:with-param name="textMessages" select="$textMessages"/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
Expand All @@ -103,6 +115,7 @@
<xsl:param name="outcome"/>
<xsl:param name="message"/>
<xsl:param name="stacktrace"/>
<xsl:param name="textMessages"/>
<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 @@ -112,7 +125,7 @@
<xsl:value-of select="$duration_hours*3600 + $duration_minutes*60 + $duration_seconds"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@outcome != 'Passed' or (not(@outcome) and ($message or $stacktrace))">
<xsl:if test="$outcome != 'Passed' or (not($outcome) and ($message or $stacktrace))">
<xsl:variable name="tag">
<xsl:choose>
<xsl:when test="$outcome = 'Failed'">failure</xsl:when>
Expand All @@ -128,6 +141,9 @@
</xsl:if>
</xsl:element>
</xsl:if>
<xsl:if test="$textMessages">
<system-out><xsl:value-of select="$textMessages"/></system-out>
</xsl:if>
</testcase>
</xsl:template>
</xsl:stylesheet>
42 changes: 42 additions & 0 deletions src/test/resources/hudson/plugins/mstest/JENKINS-17506.trx
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<TestRun id="930638c2-1646-4d97-ad3d-2b49651e7472" name="Koiti@KOU 2009-01-11 16:22:44" runUser="KOU\Koiti" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2006">
<TestRunConfiguration name="Local Test Run" id="049b43ad-25f0-49df-9c33-bd7842bc7f63">
<Description>This is a default test run configuration for a local test run.</Description>
<Deployment runDeploymentRoot="E:\Koiti\Dev\GitHudsonTest\TestResults\Koiti_KOU 2009-01-11 16_22_44">
<DeploymentItem filename="E:\Koiti\Dev\GitHudsonTest\GitHudsonTest\bin\Release\GitHudsonTest.exe" />
</Deployment>
<TestTypeSpecific />
</TestRunConfiguration>
<ResultSummary outcome="Failed">
<Counters total="1" executed="1" passed="1" error="0" failed="0" timeout="0" aborted="0" inconclusive="0" passedButRunAborted="0" notRunnable="0" notExecuted="0" disconnected="0" warning="0" completed="0" inProgress="0" pending="0" />
</ResultSummary>
<Times creation="2009-01-11T16:22:44.4687500-02:00" queuing="2009-01-11T16:22:45.9375000-02:00" start="2009-01-11T16:22:46.2343750-02:00" finish="2009-01-11T16:22:46.7187500-02:00" />
<TestDefinitions>
<UnitTest name="HasTargetTest" storage="e:\koiti\dev\githudsontest\functionstest\bin\release\functionstest.dll" id="44861a89-0ac6-f405-4b04-99f6f9d85d1e">
<Css projectStructure="" iteration="" />
<Owners>
<Owner name="" />
</Owners>
<Execution id="70be9f02-00a0-49df-8c5a-8fb84a74b210" />
<TestMethod codeBase="E:\Koiti\Dev\GitHudsonTest\FunctionsTest\bin\Release\FunctionsTest.dll" adapterTypeName="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Adapter, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" className="FunctionsTest.FibonacciTest, FunctionsTest" name="CalculaFibonacci" />
</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="44861a89-0ac6-f405-4b04-99f6f9d85d1e" executionId="70be9f02-00a0-49df-8c5a-8fb84a74b210" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" />
</TestEntries>
<Results>
<UnitTestResult executionId="70be9f02-00a0-49df-8c5a-8fb84a74b210" testId="44861a89-0ac6-f405-4b04-99f6f9d85d1e" testName="HasTargetTest" computerName="xxx-LT" startTime="2012-05-22T14:32:34.3525653-04:00" endTime="2012-05-22T14:32:41.9625760-04:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="70be9f02-00a0-49df-8c5a-8fb84a74b210" outcome="Passed">
<Output>
<TextMessages>
<Message>given RomanCalc object exists</Message>
<Message>when args I and II are passed to the Add Method</Message>
<Message>then III is returned</Message>
</TextMessages>
</Output>
</UnitTestResult>
</Results>
</TestRun>

0 comments on commit cee1fee

Please sign in to comment.