Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
517 additions
and 0 deletions.
- +47 −0 src/main/java/org/jenkinsci/plugins/xunit/types/CTestInputMetric.java
- +43 −0 src/main/java/org/jenkinsci/plugins/xunit/types/CTestType.java
- +35 −0 src/main/resources/org/jenkinsci/plugins/xunit/types/ctest-to-junit.xsl
- +15 −0 src/test/java/org/jenkinsci/plugins/xunit/types/CTestTest.java
- +256 −0 src/test/resources/org/jenkinsci/plugins/xunit/types/ctest/testcase1/input.xml
- +121 −0 src/test/resources/org/jenkinsci/plugins/xunit/types/ctest/testcase1/result.xml
@@ -0,0 +1,47 @@ | ||
package org.jenkinsci.plugins.xunit.types; | ||
|
||
import com.thalesgroup.dtkit.junit.model.JUnitModel; | ||
import com.thalesgroup.dtkit.metrics.model.InputMetricXSL; | ||
import com.thalesgroup.dtkit.metrics.model.InputType; | ||
import com.thalesgroup.dtkit.metrics.model.OutputMetric; | ||
|
||
/** | ||
* @author Gregory Boissinot | ||
*/ | ||
public class CTestInputMetric extends InputMetricXSL { | ||
|
||
@Override | ||
public InputType getToolType() { | ||
return InputType.TEST; | ||
} | ||
|
||
@Override | ||
public String getToolVersion() { | ||
return "Version N/A"; | ||
} | ||
|
||
@Override | ||
public String getToolName() { | ||
return "CTest"; | ||
} | ||
|
||
@Override | ||
public boolean isDefault() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getXslName() { | ||
return "ctest-to-junit.xsl"; | ||
} | ||
|
||
@Override | ||
public String[] getInputXsdNameList() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public OutputMetric getOutputFormatType() { | ||
return JUnitModel.OUTPUT_JUNIT_5; | ||
} | ||
} |
@@ -0,0 +1,43 @@ | ||
package org.jenkinsci.plugins.xunit.types; | ||
|
||
import com.thalesgroup.dtkit.metrics.hudson.api.descriptor.TestTypeDescriptor; | ||
import com.thalesgroup.dtkit.metrics.hudson.api.type.TestType; | ||
import com.thalesgroup.dtkit.metrics.model.InputMetric; | ||
import com.thalesgroup.dtkit.metrics.model.InputMetricException; | ||
import com.thalesgroup.dtkit.metrics.model.InputMetricFactory; | ||
import hudson.Extension; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
/** | ||
* @author Gregory Boissinot | ||
*/ | ||
public class CTestType extends TestType { | ||
|
||
@DataBoundConstructor | ||
public CTestType(String pattern, boolean ignoreNoResultFiles, boolean failIfNotNew, boolean deleteOutputFiles, boolean stopProcessingIfError) { | ||
super(pattern, failIfNotNew, ignoreNoResultFiles, deleteOutputFiles, stopProcessingIfError); | ||
} | ||
|
||
@Extension | ||
public static class CTestTypeDescriptor extends TestTypeDescriptor<CTestType> { | ||
|
||
public CTestTypeDescriptor() { | ||
super(CTestType.class, null); | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return this.getClass().getName(); | ||
} | ||
|
||
@Override | ||
public InputMetric getInputMetric() { | ||
try { | ||
return InputMetricFactory.getInstance(CTestInputMetric.class); | ||
} catch (InputMetricException e) { | ||
throw new RuntimeException("Can't create the inputMetric object for the class " + CTestInputMetric.class); | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
<xsl:output method="xml" indent="yes"/> | ||
<xsl:template match="/"> | ||
<testsuites> | ||
<xsl:variable name="buildName" select="//Site/@BuildName"/> | ||
<xsl:variable name="numberOfTests" select="count(//Site/Testing/Test)"/> | ||
<xsl:variable name="numberOfFailures" select="count(//Site/Testing/Test[@Status!='passed'])"/> | ||
<testsuite name="CTest" | ||
tests="{$numberOfTests}" time="0" | ||
failures="{$numberOfFailures}" errors="0" | ||
skipped="0"> | ||
<xsl:for-each select="//Site/Testing/Test"> | ||
<xsl:variable name="testName" select="translate(Name, '-', '_')"/> | ||
<xsl:variable name="duration" select="Results/NamedMeasurement[@name='Execution Time']/Value"/> | ||
<xsl:variable name="status" select="@Status"/> | ||
<xsl:variable name="output" select="Results/Measurement/Value"/> | ||
<xsl:variable name="className" select="translate(Path, '/.', '.')"/> | ||
<testcase classname="projectroot{$className}" | ||
name="{$testName}" | ||
time="{$duration}"> | ||
<xsl:if test="@Status!='passed'"> | ||
<failure> | ||
<xsl:value-of select="$output"/> | ||
</failure> | ||
</xsl:if> | ||
<system-out> | ||
<xsl:value-of select="$output"/> | ||
</system-out> | ||
</testcase> | ||
</xsl:for-each> | ||
</testsuite> | ||
</testsuites> | ||
</xsl:template> | ||
</xsl:stylesheet> |
@@ -0,0 +1,15 @@ | ||
package org.jenkinsci.plugins.xunit.types; | ||
|
||
import org.junit.Test; | ||
|
||
/** | ||
* @author Gregory Boissinot | ||
*/ | ||
public class CTestTest extends AbstractTest { | ||
|
||
@Test | ||
public void testTestCase1() throws Exception { | ||
convertAndValidate(CTestInputMetric.class, "ctest/testcase1/input.xml", "ctest/testcase1/result.xml"); | ||
} | ||
|
||
} |
Oops, something went wrong.