diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml
new file mode 100644
index 00000000..90787cbb
--- /dev/null
+++ b/.mvn/extensions.xml
@@ -0,0 +1,7 @@
+
+
+ io.jenkins.tools.incrementals
+ git-changelist-maven-extension
+ 1.6
+
+
diff --git a/.mvn/maven.config b/.mvn/maven.config
new file mode 100644
index 00000000..2a0299c4
--- /dev/null
+++ b/.mvn/maven.config
@@ -0,0 +1,2 @@
+-Pconsume-incrementals
+-Pmight-produce-incrementals
diff --git a/Jenkinsfile b/Jenkinsfile
index aae8d465..7d16011c 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,6 +1,9 @@
#!/usr/bin/env groovy
/* `buildPlugin` step provided by: https://github.com/jenkins-infra/pipeline-library */
-buildPlugin(jdkVersions: [8, 11])
+buildPlugin(useContainerAgent: true, configurations: [
+ [platform: 'linux', jdk: 17],
+ [platform: 'windows', jdk: 11],
+])
// More complex Jenkinsfile sample: https://github.com/jenkinsci/graphql-server-plugin/blob/master/Jenkinsfile
diff --git a/pom.xml b/pom.xml
index 424e3232..35e4c47a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -33,23 +33,24 @@ THE SOFTWARE.
org.jenkins-ci.plugins
plugin
- 4.19
+ 4.55
+
jacoco
- 3.3.3-SNAPSHOT
+ ${revision}${changelist}
hpi
Jenkins JaCoCo plugin
- https://github.com/jenkinsci/jacoco-plugin
+ https://github.com/jenkinsci/${project.artifactId}-plugin
- 8
+ 3.3.3
+ -SNAPSHOT
0.8.8
- 2.277.1
-
- 1589.vc23fca066d5c
+ 2.361.4
+ jenkinsci/${project.artifactId}-plugin
@@ -104,10 +105,10 @@ THE SOFTWARE.
- scm:git:https://github.com/jenkinsci/jacoco-plugin.git
- scm:git:git@github.com:jenkinsci/jacoco-plugin.git
- https://github.com/jenkinsci/jacoco-plugin
- HEAD
+ scm:git:https://github.com/${gitHubRepo}.git
+ scm:git:git@github.com:${gitHubRepo}.git
+ https://github.com/${gitHubRepo}
+ ${scmTag}
@@ -117,11 +118,22 @@ THE SOFTWARE.
+
+
+
+ io.jenkins.tools.bom
+ bom-2.361.x
+ 1836.vfe602c266c05
+ import
+ pom
+
+
+
+
org.jenkins-ci.plugins
dashboard-view
- 2.18.1
true
@@ -132,25 +144,19 @@ THE SOFTWARE.
org.easymock
easymock
- 4.3
- test
-
-
- org.powermock
- powermock-module-junit4
+ 5.1.0
test
- org.powermock
- powermock-api-easymock
- ${powermock.version}
+ org.mockito
+ mockito-inline
test
org.codehaus.plexus
plexus-utils
- 3.2.1
+ 3.5.1
@@ -324,21 +330,6 @@ THE SOFTWARE.
-
- org.jenkins-ci.tools
- maven-hpi-plugin
-
-
- compile
-
- hpi
-
-
-
-
- org.objectweb.asm.
-
-
diff --git a/src/main/java/hudson/plugins/jacoco/model/Coverage.java b/src/main/java/hudson/plugins/jacoco/model/Coverage.java
index e91cea32..89be248e 100644
--- a/src/main/java/hudson/plugins/jacoco/model/Coverage.java
+++ b/src/main/java/hudson/plugins/jacoco/model/Coverage.java
@@ -6,7 +6,7 @@
import org.kohsuke.stapler.export.ExportedBean;
/**
- * Represents x/y where x={@link #missed} and y={@link #covered}.
+ * Represents {@code x/y} where x={@link #missed} and y={@link #covered}.
*
* @author Kohsuke Kawaguchi
* @author Jonathan Fuerth
diff --git a/src/test/java/hudson/plugins/jacoco/BuildOverBuildTest.java b/src/test/java/hudson/plugins/jacoco/BuildOverBuildTest.java
index 8cf91d1e..5dcc5770 100644
--- a/src/test/java/hudson/plugins/jacoco/BuildOverBuildTest.java
+++ b/src/test/java/hudson/plugins/jacoco/BuildOverBuildTest.java
@@ -6,31 +6,21 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.powermock.api.easymock.PowerMock;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
+import org.mockito.MockedStatic;
import java.io.PrintStream;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.expect;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(JacocoDeltaCoverageResultSummary.class)
-// See e.g. https://issues.jenkins-ci.org/browse/JENKINS-55179
-@org.powermock.core.classloader.annotations.PowerMockIgnore({
- "com.sun.org.apache.xerces.*",
- "javax.xml.*",
- "org.xml.*",
- "javax.management.*"})
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.mockStatic;
+
public class BuildOverBuildTest {
private JacocoDeltaCoverageResultSummary jacocoDeltaCoverageResultSummary_1, jacocoDeltaCoverageResultSummary_2;
private JacocoHealthReportDeltaThresholds deltaHealthThresholds;
//private JacocoHealthReportThresholds healthThresholds;
- private Run run = PowerMock.createNiceMock(Run.class);
+ private Run run = mock(Run.class);
private final PrintStream logger = System.out;
@Before
@@ -64,19 +54,18 @@ public void setUp(){
@Test
public void shouldPassIfNegativeMetricIsWithinThresholdAndOtherMetricesArePositiveAndAboveThreshold(){
- PowerMock.mockStatic(JacocoDeltaCoverageResultSummary.class);
- //noinspection ConstantConditions
- expect(JacocoDeltaCoverageResultSummary.build(anyObject(Run.class))).andReturn(jacocoDeltaCoverageResultSummary_1);
-
- PowerMock.replay(JacocoDeltaCoverageResultSummary.class);
+ try (MockedStatic staticJacocoDeltaCoverageResultSummary =
+ mockStatic(JacocoDeltaCoverageResultSummary.class)) {
+ staticJacocoDeltaCoverageResultSummary
+ .when(() -> JacocoDeltaCoverageResultSummary.build(any()))
+ .thenReturn(jacocoDeltaCoverageResultSummary_1);
- JacocoPublisher jacocoPublisher = new JacocoPublisher();
- jacocoPublisher.deltaHealthReport = deltaHealthThresholds;
- Result result = jacocoPublisher.checkBuildOverBuildResult(run, logger);
+ JacocoPublisher jacocoPublisher = new JacocoPublisher();
+ jacocoPublisher.deltaHealthReport = deltaHealthThresholds;
+ Result result = jacocoPublisher.checkBuildOverBuildResult(run, logger);
- PowerMock.verify(JacocoDeltaCoverageResultSummary.class);
-
- Assert.assertEquals("Delta coverage drop is lesser than delta health threshold values", Result.SUCCESS, result);
+ Assert.assertEquals("Delta coverage drop is lesser than delta health threshold values", Result.SUCCESS, result);
+ }
}
@@ -84,24 +73,20 @@ public void shouldPassIfNegativeMetricIsWithinThresholdAndOtherMetricesArePositi
@Test
public void checkBuildOverBuildSuccessTest(){
- PowerMock.mockStatic(JacocoDeltaCoverageResultSummary.class);
- //noinspection ConstantConditions
- expect(JacocoDeltaCoverageResultSummary.build(anyObject(Run.class))).andReturn(jacocoDeltaCoverageResultSummary_2);
- //noinspection ConstantConditions
- expect(JacocoDeltaCoverageResultSummary.build(anyObject(Run.class))).andReturn(jacocoDeltaCoverageResultSummary_1);
-
- PowerMock.replay(JacocoDeltaCoverageResultSummary.class);
+ try (MockedStatic staticJacocoDeltaCoverageResultSummary = mockStatic(JacocoDeltaCoverageResultSummary.class)) {
+ staticJacocoDeltaCoverageResultSummary
+ .when(() -> JacocoDeltaCoverageResultSummary.build(any()))
+ .thenReturn(jacocoDeltaCoverageResultSummary_2)
+ .thenReturn(jacocoDeltaCoverageResultSummary_1);
+ JacocoPublisher jacocoPublisher = new JacocoPublisher();
+ jacocoPublisher.deltaHealthReport = deltaHealthThresholds;
+ Result result = jacocoPublisher.checkBuildOverBuildResult(run, logger); // check for first test case: delta coverage < delta threshold
- JacocoPublisher jacocoPublisher = new JacocoPublisher();
- jacocoPublisher.deltaHealthReport = deltaHealthThresholds;
- Result result = jacocoPublisher.checkBuildOverBuildResult(run, logger); // check for first test case: delta coverage < delta threshold
+ Assert.assertEquals("Delta coverage is lesser than delta health threshold values", Result.SUCCESS, result);
- Assert.assertEquals("Delta coverage is lesser than delta health threshold values", Result.SUCCESS, result);
-
- result = jacocoPublisher.checkBuildOverBuildResult(run, logger); // check for second test case: delta coverage > delta threshold but overall coverage better than last successful build
- Assert.assertEquals("Delta coverage is greater than delta health threshold values but overall coverage is better than last successful build's coverage", Result.SUCCESS, result);
-
- PowerMock.verify(JacocoDeltaCoverageResultSummary.class);
+ result = jacocoPublisher.checkBuildOverBuildResult(run, logger); // check for second test case: delta coverage > delta threshold but overall coverage better than last successful build
+ Assert.assertEquals("Delta coverage is greater than delta health threshold values but overall coverage is better than last successful build's coverage", Result.SUCCESS, result);
+ }
}
@@ -120,18 +105,16 @@ public void shouldFailIfNegativeMetricIsAboveThresholdAndOtherMetricesArePositiv
jacocoDeltaCoverageResultSummary.setBranchCoverage(0f);
jacocoDeltaCoverageResultSummary.setComplexityCoverage(-2.678f);
- PowerMock.mockStatic(JacocoDeltaCoverageResultSummary.class);
- //noinspection ConstantConditions
- expect(JacocoDeltaCoverageResultSummary.build(anyObject(Run.class))).andReturn(jacocoDeltaCoverageResultSummary);
-
- PowerMock.replay(JacocoDeltaCoverageResultSummary.class);
-
- JacocoPublisher jacocoPublisher = new JacocoPublisher();
- jacocoPublisher.deltaHealthReport = deltaHealthThresholds;
- Result result = jacocoPublisher.checkBuildOverBuildResult(run, logger);
+ try (MockedStatic staticJacocoDeltaCoverageResultSummary = mockStatic(JacocoDeltaCoverageResultSummary.class)) {
+ staticJacocoDeltaCoverageResultSummary
+ .when(() -> JacocoDeltaCoverageResultSummary.build(any()))
+ .thenReturn(jacocoDeltaCoverageResultSummary);
- PowerMock.verify(JacocoDeltaCoverageResultSummary.class);
- Assert.assertEquals("Delta coverage drop is greater than delta health threshold values", Result.FAILURE, result);
+ JacocoPublisher jacocoPublisher = new JacocoPublisher();
+ jacocoPublisher.deltaHealthReport = deltaHealthThresholds;
+ Result result = jacocoPublisher.checkBuildOverBuildResult(run, logger);
+ Assert.assertEquals("Delta coverage drop is greater than delta health threshold values", Result.FAILURE, result);
+ }
}
}
diff --git a/src/test/java/hudson/plugins/jacoco/JacocoPublisherTest.java b/src/test/java/hudson/plugins/jacoco/JacocoPublisherTest.java
index 21a53725..33abd42a 100644
--- a/src/test/java/hudson/plugins/jacoco/JacocoPublisherTest.java
+++ b/src/test/java/hudson/plugins/jacoco/JacocoPublisherTest.java
@@ -29,10 +29,6 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.powermock.api.easymock.PowerMock;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
import hudson.EnvVars;
import hudson.FilePath;
@@ -49,14 +45,6 @@
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Publisher;
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(JacocoPublisher.class)
-// See e.g. https://issues.jenkins-ci.org/browse/JENKINS-55179
-@org.powermock.core.classloader.annotations.PowerMockIgnore({
- "com.sun.org.apache.xerces.*",
- "javax.xml.*",
- "org.xml.*",
- "javax.management.*"})
public class JacocoPublisherTest extends AbstractJacocoTestBase {
private final TaskListener taskListener = niceMock(TaskListener.class);
private final Launcher launcher = niceMock(Launcher.class);
@@ -496,8 +484,8 @@ public void testCopyClass_Wrong() throws IOException, InterruptedException {
public void testPerformWithBuildOverBuild() throws IOException, InterruptedException {
// expect
- final Run run = PowerMock.createNiceMock(Run.class);
- final Job job = PowerMock.createNiceMock(Job.class);
+ final Run run = niceMock(Run.class);
+ final Job job = niceMock(Job.class);
expect(run.getResult()).andReturn(Result.SUCCESS).anyTimes();
expect(run.getEnvironment(taskListener)).andReturn(new EnvVars()).anyTimes();
@@ -522,7 +510,7 @@ public void testPerformWithBuildOverBuild() throws IOException, InterruptedExcep
expect(run.getParent()).andReturn(job).anyTimes();
expect(job.getLastSuccessfulBuild()).andReturn(run).anyTimes();
- PowerMock.replay(taskListener, run, job);
+ replay(taskListener, run, job);
// execute
//noinspection deprecation
@@ -540,6 +528,6 @@ public void testPerformWithBuildOverBuild() throws IOException, InterruptedExcep
}
// verify
- PowerMock.verify(taskListener, run, job);
+ verify(taskListener, run, job);
}
}
diff --git a/src/test/java/hudson/plugins/jacoco/portlet/JacocoDeltaCoverageResultSummaryTest.java b/src/test/java/hudson/plugins/jacoco/portlet/JacocoDeltaCoverageResultSummaryTest.java
index 19dd6ac5..f2a65f69 100644
--- a/src/test/java/hudson/plugins/jacoco/portlet/JacocoDeltaCoverageResultSummaryTest.java
+++ b/src/test/java/hudson/plugins/jacoco/portlet/JacocoDeltaCoverageResultSummaryTest.java
@@ -6,28 +6,18 @@
import hudson.plugins.jacoco.portlet.bean.JacocoDeltaCoverageResultSummary;
import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.powermock.api.easymock.PowerMock;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
+import org.mockito.MockedStatic;
-import static org.easymock.EasyMock.expect;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(JacocoLoadData.class)
-// See e.g. https://issues.jenkins-ci.org/browse/JENKINS-55179
-@org.powermock.core.classloader.annotations.PowerMockIgnore({
- "com.sun.org.apache.xerces.*",
- "javax.xml.*",
- "org.xml.*",
- "javax.management.*"})
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.mockStatic;
+import static org.mockito.Mockito.when;
+
public class JacocoDeltaCoverageResultSummaryTest {
- private final Run run = PowerMock.createNiceMock(Run.class);
- private final Job job = PowerMock.createNiceMock(Job.class);
+ private final Run run = mock(Run.class);
+ private final Job job = mock(Job.class);
JacocoCoverageResultSummary lastSuccessfulBuildCoverage, currentBuildwithMoreCoverage, currentBuildWithLesserCoverage;
@@ -59,63 +49,59 @@ public void setUp(){
@Test
public void deltaCoverageSummaryForBetterBuildTest(){
- expect(run.getParent()).andReturn(job).anyTimes();
- expect(job.getLastSuccessfulBuild()).andReturn(run).anyTimes();
- PowerMock.mockStatic(JacocoLoadData.class);
- expect(JacocoLoadData.getResult(run)).andReturn(lastSuccessfulBuildCoverage);
- expect(JacocoLoadData.getResult(run)).andReturn(currentBuildwithMoreCoverage);
-
- PowerMock.replay(run, job);
- PowerMock.replay(JacocoLoadData.class);
+ when(run.getParent()).thenReturn(job);
+ when(job.getLastSuccessfulBuild()).thenReturn(run);
- JacocoDeltaCoverageResultSummary deltaCoverageSummary = JacocoDeltaCoverageResultSummary.build(run);
+ try (MockedStatic staticJacocoLoadData = mockStatic(JacocoLoadData.class)) {
+ staticJacocoLoadData
+ .when(() -> JacocoLoadData.getResult(any()))
+ .thenReturn(lastSuccessfulBuildCoverage)
+ .thenReturn(currentBuildwithMoreCoverage);
- PowerMock.verify(run, job);
- PowerMock.verify(JacocoLoadData.class);
+ JacocoDeltaCoverageResultSummary deltaCoverageSummary = JacocoDeltaCoverageResultSummary.build(run);
- assertEquals("Absolute difference in instruction coverage",
+ assertEquals("Absolute difference in instruction coverage",
currentBuildwithMoreCoverage.getInstructionCoverage() - lastSuccessfulBuildCoverage.getInstructionCoverage(), deltaCoverageSummary.getInstructionCoverage(), 0.00001);
- assertEquals("Absolute difference in branch coverage",
+ assertEquals("Absolute difference in branch coverage",
currentBuildwithMoreCoverage.getBranchCoverage() - lastSuccessfulBuildCoverage.getBranchCoverage(), deltaCoverageSummary.getBranchCoverage(), 0.00001);
- assertEquals("Absolute difference in complexity coverage",
+ assertEquals("Absolute difference in complexity coverage",
currentBuildwithMoreCoverage.getComplexityScore() - lastSuccessfulBuildCoverage.getComplexityScore(), deltaCoverageSummary.getComplexityCoverage(), 0.00001);
- assertEquals("Absolute difference in line coverage",
+ assertEquals("Absolute difference in line coverage",
currentBuildwithMoreCoverage.getLineCoverage() - lastSuccessfulBuildCoverage.getLineCoverage(), deltaCoverageSummary.getLineCoverage(), 0.00001);
- assertEquals("Absolute difference in method coverage",
+ assertEquals("Absolute difference in method coverage",
currentBuildwithMoreCoverage.getMethodCoverage() - lastSuccessfulBuildCoverage.getMethodCoverage(), deltaCoverageSummary.getMethodCoverage(), 0.00001);
- assertEquals("Absolute difference in class coverage",
+ assertEquals("Absolute difference in class coverage",
currentBuildwithMoreCoverage.getClassCoverage() - lastSuccessfulBuildCoverage.getClassCoverage(), deltaCoverageSummary.getClassCoverage(), 0.00001);
+ }
}
// Test delta coverage summary when current build has worse coverage than previous successful build
@Test
public void deltaCoverageSummaryForWorseBuildTest(){
- expect(run.getParent()).andReturn(job).anyTimes();
- expect(job.getLastSuccessfulBuild()).andReturn(run).anyTimes();
- PowerMock.mockStatic(JacocoLoadData.class);
- expect(JacocoLoadData.getResult(run)).andReturn(lastSuccessfulBuildCoverage);
- expect(JacocoLoadData.getResult(run)).andReturn(currentBuildWithLesserCoverage);
-
- PowerMock.replay(run, job);
- PowerMock.replay(JacocoLoadData.class);
+ when(run.getParent()).thenReturn(job);
+ when(job.getLastSuccessfulBuild()).thenReturn(run);
- JacocoDeltaCoverageResultSummary deltaCoverageSummary = JacocoDeltaCoverageResultSummary.build(run);
+ try (MockedStatic staticJacocoLoadData = mockStatic(JacocoLoadData.class)) {
+ staticJacocoLoadData
+ .when(() -> JacocoLoadData.getResult(any()))
+ .thenReturn(lastSuccessfulBuildCoverage)
+ .thenReturn(currentBuildWithLesserCoverage);
- PowerMock.verify(run, job);
- PowerMock.verify(JacocoLoadData.class);
+ JacocoDeltaCoverageResultSummary deltaCoverageSummary = JacocoDeltaCoverageResultSummary.build(run);
- assertEquals("Absolute difference in instruction coverage",
+ assertEquals("Absolute difference in instruction coverage",
currentBuildWithLesserCoverage.getInstructionCoverage() - lastSuccessfulBuildCoverage.getInstructionCoverage(), deltaCoverageSummary.getInstructionCoverage(), 0.00001);
- assertEquals("Absolute difference in branch coverage",
+ assertEquals("Absolute difference in branch coverage",
currentBuildWithLesserCoverage.getBranchCoverage() - lastSuccessfulBuildCoverage.getBranchCoverage(), deltaCoverageSummary.getBranchCoverage(), 0.00001);
- assertEquals("Absolute difference in complexity coverage",
+ assertEquals("Absolute difference in complexity coverage",
currentBuildWithLesserCoverage.getComplexityScore() - lastSuccessfulBuildCoverage.getComplexityScore(), deltaCoverageSummary.getComplexityCoverage(), 0.00001);
- assertEquals("Absolute difference in line coverage",
+ assertEquals("Absolute difference in line coverage",
currentBuildWithLesserCoverage.getLineCoverage() - lastSuccessfulBuildCoverage.getLineCoverage(), deltaCoverageSummary.getLineCoverage(), 0.00001);
- assertEquals("Absolute difference in method coverage",
+ assertEquals("Absolute difference in method coverage",
currentBuildWithLesserCoverage.getMethodCoverage() - lastSuccessfulBuildCoverage.getMethodCoverage(), deltaCoverageSummary.getMethodCoverage(), 0.00001);
- assertEquals("Absolute difference in class coverage",
+ assertEquals("Absolute difference in class coverage",
currentBuildWithLesserCoverage.getClassCoverage() - lastSuccessfulBuildCoverage.getClassCoverage(), deltaCoverageSummary.getClassCoverage(), 0.00001);
+ }
}
}
diff --git a/src/test/java/hudson/plugins/jacoco/portlet/JacocoLoadDataHudsonTest.java b/src/test/java/hudson/plugins/jacoco/portlet/JacocoLoadDataHudsonTest.java
index 47b032ea..c292f31a 100644
--- a/src/test/java/hudson/plugins/jacoco/portlet/JacocoLoadDataHudsonTest.java
+++ b/src/test/java/hudson/plugins/jacoco/portlet/JacocoLoadDataHudsonTest.java
@@ -18,12 +18,6 @@
* @author Robert Sandell <robert.sandell@sonyericsson.com>
* @author Mauro Durante Junior (Mauro.Durantejunior@sonyericsson.com)
*/
-// See e.g. https://issues.jenkins-ci.org/browse/JENKINS-55179
-@org.powermock.core.classloader.annotations.PowerMockIgnore({
- "com.sun.org.apache.xerces.*",
- "javax.xml.*",
- "org.xml.*",
- "javax.management.*"})
public class JacocoLoadDataHudsonTest extends HudsonTestCase {
/**