Qu'est-ce que XSLT convertit le format JUnit Xml en format JUnit Plain?
je déplace ma construction de fourmi à Grad. Ant permet la création de rapports multiples avec différents formats par la tâche JUnit. Gradle est plus restrictif: il génère un rapport HTML et un rapport XML. Le rapport XML est un super-ensemble du rapport de texte JUnit de sorte qu'il peut être transformé de l'un à l'autre. Quel XSLT convertira le XML en texte? Voici un exemple de XML:
<?xml version="1.0" encoding="UTF-8"?>
<testsuite errors="0" failures="0" hostname="spina.stsci.edu" name="edu.stsci.CoSI.test.DependencySupressingConstraintJUnitTest" tests="6" time="0.14" timestamp="2012-02-27T18:08:03">
<properties />
<testcase classname="edu.stsci.CoSI.test.DependencySupressingConstraintJUnitTest" name="testSupressionWorks" time="0.01" />
<testcase classname="edu.stsci.CoSI.test.DependencySupressingConstraintJUnitTest" name="testSupressionWorksWithDependenciesDisabled" time="0.0020" />
<testcase classname="edu.stsci.CoSI.test.DependencySupressingConstraintJUnitTest" name="testPropagationIsDeferred" time="0.0010" />
<testcase classname="edu.stsci.CoSI.test.DependencySupressingConstraintJUnitTest" name="testPropagationIsDeferredWhenDependenciesAreSuppressed" time="0.0010" />
<testcase classname="edu.stsci.CoSI.test.DependencySupressingConstraintJUnitTest" name="testPropagationIsDeferredWhenDependenciesAreSuppressed2" time="0.0010" />
<testcase classname="edu.stsci.CoSI.test.DependencySupressingConstraintJUnitTest" name="testGarbageCollection" time="0.066" />
<system-out><![CDATA[Running Supressing Constraint
Running Supressing Constraint
Running Supressing Constraint
Change Me is: 2
Running Supressing Constraint
Change Me is: 5
]]></system-out>
<system-err><![CDATA[]]></system-err>
</testsuite>
voici le texte que je voudrais qu'il produise:
Testsuite: edu.stsci.CoSI.test.DependencySupressingConstraintJUnitTest
Tests run: 6, Failures: 0, Errors: 0, Time elapsed: 0.363 sec
------------- Standard Output ---------------
Running Supressing Constraint
Running Supressing Constraint
Running Supressing Constraint
Change Me is: 2
Running Supressing Constraint
Change Me is: 5
------------- ---------------- ---------------
Testcase: testSupressionWorks took 0.001 sec
Testcase: testSupressionWorksWithDependenciesDisabled took 0.001 sec
Testcase: testPropagationIsDeferred took 0 sec
Testcase: testPropagationIsDeferredWhenDependenciesAreSuppressed took 0.001 sec
Testcase: testPropagationIsDeferredWhenDependenciesAreSuppressed2 took 0 sec
Testcase: testGarbageCollection took 0.038 sec
certains détails ne sont pas importants (comme le format des secondes).
2
demandé sur
Spina
2012-02-27 22:18:10
1 réponses
voilà.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" indent="no"/>
<xsl:template match="/testsuite">
Testsuite: <xsl:value-of select="@name" />
<xsl:text>
Tests run: </xsl:text>
<xsl:value-of select="@tests" />
<xsl:text>, Failures: </xsl:text>
<xsl:value-of select="@failures" />
<xsl:text>, Errors: </xsl:text>
<xsl:value-of select="@errors" />
<xsl:text>, Time elapsed: </xsl:text>
<xsl:value-of select="@time" />
<xsl:text> sec</xsl:text>
<xsl:apply-templates select="system-out" />
<xsl:apply-templates select="system-err" />
<xsl:text>
--------- ----------- ---------
</xsl:text>
<xsl:apply-templates select="testcase" />
</xsl:template>
<xsl:template match="testcase">
<xsl:text>
Testcase: </xsl:text>
<xsl:value-of select="@name" />
<xsl:text> took </xsl:text>
<xsl:value-of select="@time" />
</xsl:template>
<xsl:template match="system-out">
<xsl:text>
------ Standard output ------
</xsl:text>
<xsl:value-of select="." />
</xsl:template>
<xsl:template match="system-err">
<xsl:text>
------ Error output ------
</xsl:text>
<xsl:value-of select="." />
</xsl:template>
</xsl:stylesheet>
vous voulez probablement jouer un peu avec le formatage cependant.
8
répondu
dvdvorle
2012-02-27 20:05:37