Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for XUnit .NET format #72

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The Jenkins Coverage Plug-in collects reports of code coverage or mutation cover
- [PIT](https://pitest.org/): Mutation Coverage
- [JUnit](https://ant.apache.org/manual/Tasks/junitreport.html): Test Results
- [NUnit](https://nunit.org/): Test Results
- [XUnit](https://xunit.net/): Test Results

If your coverage tool is not yet supported by the coverage plugin, feel free to provide a pull request for the [Coverage Model](https://github.com/jenkinsci/coverage-model/pulls).

Expand Down Expand Up @@ -109,6 +110,7 @@ The Coverage Plug-in supports the following report formats:
- [PIT](https://pitest.org/): Mutation Coverage
- [JUnit](https://ant.apache.org/manual/Tasks/junitreport.html): Test Results
- [NUnit](https://nunit.org/): Test Results
- [XUnit](https://xunit.net/): Test Results

Some of these report files are generated by other tools and may contain invalid or inconsistent information. By default, the plugin tries to fail fast if such a broken file is detected. You can disable this behavior by setting the property `ignoreParsingErrors` to `true`. In this case, the plugin will try to parse as much information as possible from the report file.

Expand Down
2 changes: 1 addition & 1 deletion plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<gitHubRepo>jenkinsci/coverage-plugin</gitHubRepo>

<!-- Library Dependencies Versions -->
<coverage-model.version>0.39.0</coverage-model.version>
<coverage-model.version>0.40.0</coverage-model.version>
<jsoup.version>1.17.2</jsoup.version>

<!-- Jenkins Plug-in Dependencies Versions -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ public enum Parser {
JUNIT(Messages._Parser_Junit(), "**/TEST-*.xml",
"symbol-solid/list-check plugin-font-awesome-api"),
NUNIT(Messages._Parser_Nunit(), "**/nunit.xml,**/TestResult.xml",
"symbol-solid/list-check plugin-font-awesome-api"),
XUNIT(Messages._Parser_Xunit(), "**/xunit.xml,**/TestResult.xml",
"symbol-solid/list-check plugin-font-awesome-api");

private final Localizable displayName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Parser.OpenCover=OpenCover Coverage Reports
Parser.PIT=PIT Mutation Testing Reports
Parser.Junit=JUnit Test Results
Parser.Nunit=NUnit Test Results
Parser.Xunit=XUnit Test Results

Coverage.Not.Available=n/a
Coverage.Link.Name=Coverage Report
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,19 +411,34 @@

@Test
void shouldRecordOneNUnitResultInFreestyleJob() {
FreeStyleProject project = createFreestyleJob(Parser.NUNIT, "nunit.xml");

Run<?, ?> build = buildSuccessfully(project);

CoverageBuildAction coverageResult = build.getAction(CoverageBuildAction.class);
assertThat(coverageResult.getAllValues(Baseline.PROJECT))
.filteredOn(Value::getMetric, Metric.TESTS)
.first()
.isInstanceOfSatisfying(TestCount.class, m -> {
assertThat(m.getValue()).isEqualTo(4);

Check warning on line 423 in plugin/src/test/java/io/jenkins/plugins/coverage/metrics/steps/CoveragePluginITest.java

View check run for this annotation

ci.jenkins.io / CPD

CPD

LOW: Found duplicated code.
Raw output
<pre><code>FreeStyleProject project &#61; createFreestyleJob(Parser.NUNIT, &#34;nunit.xml&#34;); Run&lt;?, ?&gt; build &#61; buildSuccessfully(project); CoverageBuildAction coverageResult &#61; build.getAction(CoverageBuildAction.class); assertThat(coverageResult.getAllValues(Baseline.PROJECT)) .filteredOn(Value::getMetric, Metric.TESTS) .first() .isInstanceOfSatisfying(TestCount.class, m -&gt; { assertThat(m.getValue()).isEqualTo(4);</code></pre>
});
}

@Test
void shouldRecordOneXUnitResultInFreestyleJob() {
FreeStyleProject project = createFreestyleJob(Parser.XUNIT, "xunit.xml");

Run<?, ?> build = buildSuccessfully(project);

CoverageBuildAction coverageResult = build.getAction(CoverageBuildAction.class);
assertThat(coverageResult.getAllValues(Baseline.PROJECT))
.filteredOn(Value::getMetric, Metric.TESTS)
.first()
.isInstanceOfSatisfying(TestCount.class, m -> {
assertThat(m.getValue()).isEqualTo(3);

Check warning on line 438 in plugin/src/test/java/io/jenkins/plugins/coverage/metrics/steps/CoveragePluginITest.java

View check run for this annotation

ci.jenkins.io / CPD

CPD

LOW: Found duplicated code.
Raw output
<pre><code>FreeStyleProject project &#61; createFreestyleJob(Parser.NUNIT, &#34;nunit.xml&#34;); Run&lt;?, ?&gt; build &#61; buildSuccessfully(project); CoverageBuildAction coverageResult &#61; build.getAction(CoverageBuildAction.class); assertThat(coverageResult.getAllValues(Baseline.PROJECT)) .filteredOn(Value::getMetric, Metric.TESTS) .first() .isInstanceOfSatisfying(TestCount.class, m -&gt; { assertThat(m.getValue()).isEqualTo(4);</code></pre>
});
}

@Test
void shouldRecordOnePitResultInFreestyleJob() {
FreeStyleProject project = createFreestyleJob(Parser.PIT, "mutations.xml");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<assemblies timestamp="01/26/2024 13:49:51">
<assembly name="/home/jenkins/test2/bin/Debug/net8.0/test2.dll" run-date="2024-01-26" run-time="13:49:51" total="3" passed="1" failed="1" skipped="1" time="1.100" errors="0">
<errors />
<collection total="3" passed="1" failed="1" skipped="1" name="Test collection for test.Tests2" time="0.005">
<test name="test.Tests2.ShouldCreateItem" type="test.Tests2" method="ShouldCreateItem" time="0.0026206" result="Pass">
<traits />
</test>
<test name="test.Tests2.ShouldCreateItem3" type="test.Tests2" method="ShouldCreateItem3" time="0.0010000" result="Skip">
<reason><![CDATA[specific reason]]></reason>
<output>specific reason
</output>
<traits />
</test>
<test name="test.Tests2.ShouldCreateItem2" type="test.Tests2" method="ShouldCreateItem2" time="0.0010159" result="Fail">
<failure>
<message>Assert.Equal() Failure
↓ (pos 4)
Expected: Test3
Actual: Test
↑ (pos 4)</message>
<stack-trace> at test.Tests2.ShouldCreateItem2() in /home/jenkins/test2/Tests2.cs:line 36
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)</stack-trace>
</failure>
<traits />
</test>
</collection>
</assembly>
</assemblies>
Loading