Created
April 12, 2017 11:26
-
-
Save cooperaj/257032b6db68dd2ba6872baca3ad0cb5 to your computer and use it in GitHub Desktop.
XSLT transform to fix PHPunit junit output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- | |
PHPUnit does not output valid junit files. This XSLT file transforms the | |
output it does have to be valid. | |
Found here on a jetbrains Teamcity issue (they added an exception to their | |
junit parser since PHPUnit shows no inclination to change): | |
https://youtrack.jetbrains.com/issue/TW-17249#comment=27-231993 | |
--> | |
<xsl:stylesheet | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
version="2.0"> | |
<xsl:output method="xml"/> | |
<xsl:template match="/"> | |
<xsl:for-each select="//testsuite[@file]"> | |
<xsl:variable name="filename" select="concat('TEST-',@name,'.xml')" /> | |
<xsl:result-document href="{$filename}" method="xml"> | |
<xsl:copy-of select="." /> | |
</xsl:result-document> | |
</xsl:for-each> | |
</xsl:template> | |
</xsl:stylesheet> |
I've got this working in VSTS thanks to your script!!!
@jeffbeagley I downloaded the Saxon 9 HE Jar file, put that in my repository, and I ran:
java -jar saxon9he.jar -xsl:phpunit_to_junit.xsl -s:test-results.xml
You will need to write this script to execute in the proper location of your test result files, names, etc. of course. If you run into any issues let me know, I can further explain how I got this working.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you have an example of the usage for this? Thanks