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

Include NUnit parser from coverage-model #66

Merged
merged 1 commit into from
Jan 24, 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The Jenkins Coverage Plug-in collects reports of code coverage or mutation cover
- [OpenCover](https://github.com/OpenCover/opencover): Code Coverage
- [PIT](https://pitest.org/): Mutation Coverage
- [JUnit](https://ant.apache.org/manual/Tasks/junitreport.html): Test Results
- [NUnit](https://nunit.org/): 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
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.38.0</coverage-model.version>
<coverage-model.version>0.39.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 @@ -151,6 +151,7 @@
add(options, Parser.OPENCOVER);
add(options, Parser.PIT);
add(options, Parser.JUNIT);
add(options, Parser.NUNIT);

Check warning on line 154 in plugin/src/main/java/io/jenkins/plugins/coverage/metrics/steps/CoverageTool.java

View workflow job for this annotation

GitHub Actions / pitest

A change can be made to line 154 without causing a test to fail

removed call to io/jenkins/plugins/coverage/metrics/steps/CoverageTool$CoverageToolDescriptor::add (no tests cover this line VoidMethodCallMutator)

Check warning on line 154 in plugin/src/main/java/io/jenkins/plugins/coverage/metrics/steps/CoverageTool.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 154 is not covered by tests

Check warning on line 154 in plugin/src/main/java/io/jenkins/plugins/coverage/metrics/steps/CoverageTool.java

View check run for this annotation

Codecov / codecov/patch

plugin/src/main/java/io/jenkins/plugins/coverage/metrics/steps/CoverageTool.java#L154

Added line #L154 was not covered by tests
return options;
}
return new ListBoxModel();
Expand Down Expand Up @@ -213,6 +214,8 @@
PIT(Messages._Parser_PIT(), "**/mutations.xml",
"symbol-solid/virus-slash plugin-font-awesome-api"),
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");

private final Localizable displayName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Parser.JaCoCo=JaCoCo Coverage Reports
Parser.OpenCover=OpenCover Coverage Reports
Parser.PIT=PIT Mutation Testing Reports
Parser.Junit=JUnit Test Results
Parser.Nunit=NUnit 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 @@ -11,6 +11,7 @@
import edu.hm.hafner.coverage.Coverage;
import edu.hm.hafner.coverage.Coverage.CoverageBuilder;
import edu.hm.hafner.coverage.Metric;
import edu.hm.hafner.coverage.TestCount;
import edu.hm.hafner.coverage.Value;

import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
Expand Down Expand Up @@ -408,6 +409,21 @@ void shouldRecordOneOpenCoverResultInFreestyleJob() {
});
}

@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);
});
}

@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 @@
<test-run id="2" duration="0.46225700000000003" testcasecount="4" total="4" passed="2" failed="1" inconclusive="0" skipped="1" result="Failed" start-time="2024-01-23T 12:33:37Z" end-time="2024-01-23T 12:33:47Z">
<test-suite type="Assembly" name="test.dll" fullname="/home/jenkins/bin/Debug/net8.0/test.dll" total="4" passed="2" failed="1" inconclusive="0" skipped="1" result="Failed" start-time="2024-01-23T 12:33:46Z" end-time="2024-01-23T 12:33:47Z" duration="0.462257">
<test-suite type="TestSuite" name="test" fullname="test" total="4" passed="2" failed="1" inconclusive="0" skipped="1" result="Failed" start-time="2024-01-23T 12:33:46Z" end-time="2024-01-23T 12:33:47Z" duration="0.462257">
<test-suite type="TestFixture" name="Tests" fullname="test.Tests" classname="test.Tests" total="4" passed="2" failed="1" inconclusive="0" skipped="1" result="Failed" start-time="2024-01-23T 12:33:46Z" end-time="2024-01-23T 12:33:47Z" duration="0.462257">
<test-case name="FailedTEst" fullname="test.Tests.FailedTEst" methodname="FailedTEst" classname="Tests" result="Failed" start-time="2024-01-23T 12:33:46Z" end-time="2024-01-23T 12:33:46Z" duration="0.057283" asserts="0" seed="1556857297">
<failure>
<message> Expected string length 4 but was 5. Strings differ at index 4.
Expected: "Test"
But was: "Test1"
---------------^
</message>
<stack-trace> at test.Tests.FailedTEst() in /home/jenkins/Tests.cs:line 50

1) at test.Tests.FailedTEst() in /home/jenkins/Tests.cs:line 50

</stack-trace>
</failure>
</test-case>
<test-case name="IgnoredTest" fullname="test.Tests.IgnoredTest" methodname="IgnoredTest" classname="Tests" result="Skipped" start-time="2024-01-23T 12:33:46Z" end-time="2024-01-23T 12:33:46Z" duration="0.000378" asserts="0" seed="1438305193">
<output><![CDATA[Skipping this test
]]></output>
</test-case>
<test-case name="ShouldConnectToDatabase" fullname="test.Tests.ShouldConnectToDatabase" methodname="ShouldConnectToDatabase" classname="Tests" result="Passed" start-time="2024-01-23T 12:33:46Z" end-time="2024-01-23T 12:33:47Z" duration="0.404245" asserts="0" seed="802014458" />
<test-case name="ShouldCreateItem" fullname="test.Tests.ShouldCreateItem" methodname="ShouldCreateItem" classname="Tests" result="Passed" start-time="2024-01-23T 12:33:47Z" end-time="2024-01-23T 12:33:47Z" duration="0.000351" asserts="0" seed="606875445" />
</test-suite>
</test-suite>
<errors />
</test-suite>
</test-run>
Loading