From 4eae871077e2aa50ded74f4fea3b60fe088b5b8a Mon Sep 17 00:00:00 2001 From: Alexey Elin Date: Tue, 7 Apr 2020 21:37:11 +0300 Subject: [PATCH 1/5] migrate to mockito 3: update versions, fix tests and deprecated API usage --- .../java/org/pitest/ant/PitestTaskTest.java | 11 +++++----- .../commandline/OptionsParserTest.java | 2 +- .../java/com/example/MockitoRunnerTest.java | 2 +- .../org/pitest/classinfo/RepositoryTest.java | 4 ++-- .../org/pitest/coverage/CoverageDataTest.java | 2 +- .../CompoundMutationInterceptorTest.java | 4 ++-- .../build/DefaultTestPrioritiserTest.java | 2 +- .../build/MutationSourceTest.java | 4 ++-- .../build/MutationTestBuilderTest.java | 2 +- .../config/CompoundListenerFactoryTest.java | 12 +++-------- .../incremental/IncrementalAnalyserTest.java | 5 +++-- .../ObjectOutputStreamHistoryStoreTest.java | 2 +- .../tooling/DirectorySourceLocatorTest.java | 2 +- .../tooling/JarCreatingJarFinderTest.java | 2 +- .../tooling/MutationCoverageReportTest.java | 11 +++++----- .../util/SocketReadingCallableTest.java | 4 ++-- .../TestJUnitConfigurationForSpock.java | 2 +- .../html/MutationHtmlReportListenerTest.java | 4 ++-- .../test/resources/pit-183-gwtmockito/pom.xml | 4 ++-- .../src/test/java/sample/MyWidgetTest.java | 2 +- .../org/pitest/maven/BasePitMojoTest.java | 14 +------------ .../MojoToReportOptionsConverterTest.java | 5 +++-- .../pitest/maven/NonEmptyProjectCheckIT.java | 2 +- .../java/org/pitest/maven/PitMojoTest.java | 16 ++++++--------- .../java/org/pitest/maven/ScmMojoTest.java | 20 +++++++++---------- .../maven/report/PitReportMojoTest.java | 2 +- .../maven/report/ReportSourceLocatorTest.java | 2 +- .../ReportGenerationManagerTest.java | 2 +- .../org/pitest/TestJUnitConfiguration.java | 2 +- .../pitest/bytecode/MethodDecoratorTest.java | 4 ++-- .../org/pitest/classinfo/RepositoryTest.java | 4 ++-- .../org/pitest/classpath/ClassPathTest.java | 4 ++-- .../classpath/CompoundClassPathRootTest.java | 2 +- ...estContainersSendCorrectNotifications.java | 2 +- .../coverage/codeassist/LineMapperTest.java | 4 ++-- .../execute/DependencyFilterTest.java | 17 ++++++++-------- .../adapter/AdaptedJUnitTestUnitTest.java | 4 ++-- .../adapter/CustomRunnerExecutorTest.java | 2 +- .../gregor/AvoidAssertsMethodAdapterTest.java | 2 +- .../AvoidStringSwitchedMethodAdapterTest.java | 2 +- .../execute/MutationTestMinionTest.java | 2 +- .../execute/MutationTestWorkerTest.java | 2 +- .../execute/MutationTimeoutDecoratorTest.java | 2 +- .../BendJavassistToMyWillTransformerTest.java | 2 +- .../pitest/testapi/execute/TestPitest.java | 2 +- .../org/pitest/testng/TestNGTestUnitTest.java | 8 +++----- .../util/CachingByteArraySourceTest.java | 2 +- pom.xml | 4 ++-- 48 files changed, 97 insertions(+), 122 deletions(-) diff --git a/pitest-ant/src/test/java/org/pitest/ant/PitestTaskTest.java b/pitest-ant/src/test/java/org/pitest/ant/PitestTaskTest.java index 5c836295b..b103905db 100644 --- a/pitest-ant/src/test/java/org/pitest/ant/PitestTaskTest.java +++ b/pitest-ant/src/test/java/org/pitest/ant/PitestTaskTest.java @@ -15,8 +15,8 @@ package org.pitest.ant; -import static org.mockito.Matchers.argThat; -import static org.mockito.Matchers.startsWith; +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.ArgumentMatchers.startsWith; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -36,7 +36,7 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentMatcher; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.pitest.mutationtest.commandline.MutationCoverageReport; @RunWith(MockitoJUnitRunner.class) @@ -482,7 +482,7 @@ public void shouldPassMutationMatrixFlagToJavaTask() { verify(this.arg).setValue("--fullMutationMatrix=true"); } - private static class PathMatcher extends ArgumentMatcher { + private static class PathMatcher implements ArgumentMatcher { private final String[] expectedPaths; @@ -491,8 +491,7 @@ public PathMatcher(final String path) { } @Override - public boolean matches(final Object argument) { - final Path argPath = (Path) argument; + public boolean matches(final Path argPath) { final String[] paths = argPath.toString().split(File.pathSeparator); final boolean matches = paths.length == this.expectedPaths.length; if (matches) { diff --git a/pitest-command-line/src/test/java/org/pitest/mutationtest/commandline/OptionsParserTest.java b/pitest-command-line/src/test/java/org/pitest/mutationtest/commandline/OptionsParserTest.java index 477cb83a0..565a7bf7c 100644 --- a/pitest-command-line/src/test/java/org/pitest/mutationtest/commandline/OptionsParserTest.java +++ b/pitest-command-line/src/test/java/org/pitest/mutationtest/commandline/OptionsParserTest.java @@ -20,7 +20,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; import static org.pitest.mutationtest.config.ReportOptions.DEFAULT_CHILD_JVM_ARGS; diff --git a/pitest-entry/src/test/java/com/example/MockitoRunnerTest.java b/pitest-entry/src/test/java/com/example/MockitoRunnerTest.java index 32eb038b5..67fff6cb6 100644 --- a/pitest-entry/src/test/java/com/example/MockitoRunnerTest.java +++ b/pitest-entry/src/test/java/com/example/MockitoRunnerTest.java @@ -19,7 +19,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class MockitoRunnerTest { diff --git a/pitest-entry/src/test/java/org/pitest/classinfo/RepositoryTest.java b/pitest-entry/src/test/java/org/pitest/classinfo/RepositoryTest.java index 81f79a857..4b7fb6f3b 100644 --- a/pitest-entry/src/test/java/org/pitest/classinfo/RepositoryTest.java +++ b/pitest-entry/src/test/java/org/pitest/classinfo/RepositoryTest.java @@ -17,8 +17,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; diff --git a/pitest-entry/src/test/java/org/pitest/coverage/CoverageDataTest.java b/pitest-entry/src/test/java/org/pitest/coverage/CoverageDataTest.java index 0291f8ef8..81388cfc0 100644 --- a/pitest-entry/src/test/java/org/pitest/coverage/CoverageDataTest.java +++ b/pitest-entry/src/test/java/org/pitest/coverage/CoverageDataTest.java @@ -19,7 +19,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.pitest.coverage.CoverageMother.aBlockLocation; diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/build/CompoundMutationInterceptorTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/build/CompoundMutationInterceptorTest.java index 29b00db3e..30b914c30 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/build/CompoundMutationInterceptorTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/build/CompoundMutationInterceptorTest.java @@ -1,7 +1,7 @@ package org.pitest.mutationtest.build; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.pitest.mutationtest.engine.MutationDetailsMother.aMutationDetail; @@ -13,7 +13,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.pitest.bytecode.analysis.ClassTree; import org.pitest.mutationtest.engine.Mutater; import org.pitest.mutationtest.engine.MutationDetails; diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/build/DefaultTestPrioritiserTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/build/DefaultTestPrioritiserTest.java index c2f455915..155e14a8c 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/build/DefaultTestPrioritiserTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/build/DefaultTestPrioritiserTest.java @@ -1,7 +1,7 @@ package org.pitest.mutationtest.build; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; import static org.pitest.mutationtest.LocationMother.aLocation; diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/build/MutationSourceTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/build/MutationSourceTest.java index 0f98d3d20..a6e012bf9 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/build/MutationSourceTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/build/MutationSourceTest.java @@ -1,7 +1,7 @@ package org.pitest.mutationtest.build; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; import static org.pitest.mutationtest.LocationMother.aLocation; @@ -15,7 +15,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.pitest.classinfo.ClassByteArraySource; import org.pitest.classinfo.ClassName; import org.pitest.classpath.ClassloaderByteArraySource; diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/build/MutationTestBuilderTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/build/MutationTestBuilderTest.java index fb5f2af03..31279e812 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/build/MutationTestBuilderTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/build/MutationTestBuilderTest.java @@ -2,7 +2,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; import static org.pitest.mutationtest.LocationMother.aLocation; import static org.pitest.mutationtest.LocationMother.aMutationId; diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/config/CompoundListenerFactoryTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/config/CompoundListenerFactoryTest.java index 7ca3321c4..fc585f6c7 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/config/CompoundListenerFactoryTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/config/CompoundListenerFactoryTest.java @@ -14,20 +14,18 @@ */ package org.pitest.mutationtest.config; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.util.Arrays; -import java.util.Properties; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.pitest.mutationtest.ListenerArguments; import org.pitest.mutationtest.MutationResultListener; import org.pitest.mutationtest.MutationResultListenerFactory; @@ -52,12 +50,8 @@ public void setUp() { public void shouldCreateACombinedListenerForAllChildFactories() { final MutationResultListener listenerOne = mock(MutationResultListener.class); final MutationResultListener listenerTwo = mock(MutationResultListener.class); - when( - this.firstChild.getListener(any(Properties.class), - any(ListenerArguments.class))).thenReturn(listenerOne); - when( - this.secondChild.getListener(any(Properties.class), - any(ListenerArguments.class))).thenReturn(listenerTwo); + when(this.firstChild.getListener(isNull(), isNull())).thenReturn(listenerOne); + when(this.secondChild.getListener(isNull(), isNull())).thenReturn(listenerTwo); this.testee.getListener(null, null).runStart(); verify(listenerOne, times(1)).runStart(); verify(listenerTwo, times(1)).runStart(); diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/IncrementalAnalyserTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/IncrementalAnalyserTest.java index f1f1c3f3e..8e5170e95 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/IncrementalAnalyserTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/IncrementalAnalyserTest.java @@ -1,7 +1,8 @@ package org.pitest.mutationtest.incremental; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.isNull; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; import static org.pitest.mutationtest.LocationMother.aLocation; import static org.pitest.mutationtest.LocationMother.aMutationId; @@ -59,7 +60,7 @@ public void shouldStartPreviousSurvivedMutationsAtAStatusOfNotStartedWhenCoverag setHistoryForAllMutationsTo(DetectionStatus.SURVIVED); when( this.history.hasCoverageChanged(any(ClassName.class), - any(BigInteger.class))).thenReturn(true); + isNull())).thenReturn(true); final Collection actual = this.testee.analyse(Collections .singletonList(md)); assertEquals(DetectionStatus.NOT_STARTED, actual.iterator().next() diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/ObjectOutputStreamHistoryStoreTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/ObjectOutputStreamHistoryStoreTest.java index 8ac52e045..8804da1ce 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/ObjectOutputStreamHistoryStoreTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/ObjectOutputStreamHistoryStoreTest.java @@ -3,7 +3,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; import java.io.IOException; diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/DirectorySourceLocatorTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/DirectorySourceLocatorTest.java index ec50319bc..7660c91f7 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/DirectorySourceLocatorTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/DirectorySourceLocatorTest.java @@ -14,7 +14,7 @@ */ package org.pitest.mutationtest.tooling; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/JarCreatingJarFinderTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/JarCreatingJarFinderTest.java index d9eb3199d..8e808830b 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/JarCreatingJarFinderTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/JarCreatingJarFinderTest.java @@ -16,7 +16,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.anyString; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; import java.io.File; diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/MutationCoverageReportTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/MutationCoverageReportTest.java index f0b00ce4d..03f12f268 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/MutationCoverageReportTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/MutationCoverageReportTest.java @@ -16,7 +16,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.anyCollection; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -24,13 +25,11 @@ import java.io.IOException; import java.util.Arrays; import java.util.Collections; -import java.util.List; -import java.util.Properties; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import org.mockito.Matchers; +import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.pitest.classinfo.ClassByteArraySource; @@ -108,7 +107,7 @@ public void setUp() { this.data.setSourceDirs(Collections. emptyList()); when(this.coverage.calculateCoverage()).thenReturn(this.coverageDb); when( - this.listenerFactory.getListener(Matchers. any(), + this.listenerFactory.getListener(any(), any(ListenerArguments.class))).thenReturn(this.listener); mockMutationEngine(); } @@ -152,7 +151,7 @@ public void shouldRecordClassPath() { when(this.code.getCodeUnderTestNames()).thenReturn( Collections.singleton(clazz)); - when(this.code.getClassInfo(any(List.class))).thenReturn( + when(this.code.getClassInfo(anyCollection())).thenReturn( Collections.singletonList(foo)); createAndRunTestee(); diff --git a/pitest-entry/src/test/java/org/pitest/util/SocketReadingCallableTest.java b/pitest-entry/src/test/java/org/pitest/util/SocketReadingCallableTest.java index a26d0a25f..6239bb297 100644 --- a/pitest-entry/src/test/java/org/pitest/util/SocketReadingCallableTest.java +++ b/pitest-entry/src/test/java/org/pitest/util/SocketReadingCallableTest.java @@ -1,8 +1,8 @@ package org.pitest.util; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyByte; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyByte; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; diff --git a/pitest-groovy-verification/src/test/java/org/pitest/groovy/verification/TestJUnitConfigurationForSpock.java b/pitest-groovy-verification/src/test/java/org/pitest/groovy/verification/TestJUnitConfigurationForSpock.java index 5892451fb..14d636e39 100644 --- a/pitest-groovy-verification/src/test/java/org/pitest/groovy/verification/TestJUnitConfigurationForSpock.java +++ b/pitest-groovy-verification/src/test/java/org/pitest/groovy/verification/TestJUnitConfigurationForSpock.java @@ -1,6 +1,6 @@ package org.pitest.groovy.verification; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; diff --git a/pitest-html-report/src/test/java/org/pitest/mutationtest/report/html/MutationHtmlReportListenerTest.java b/pitest-html-report/src/test/java/org/pitest/mutationtest/report/html/MutationHtmlReportListenerTest.java index 97d867306..736bc4e4c 100644 --- a/pitest-html-report/src/test/java/org/pitest/mutationtest/report/html/MutationHtmlReportListenerTest.java +++ b/pitest-html-report/src/test/java/org/pitest/mutationtest/report/html/MutationHtmlReportListenerTest.java @@ -14,8 +14,8 @@ */ package org.pitest.mutationtest.report.html; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; diff --git a/pitest-maven-verification/src/test/resources/pit-183-gwtmockito/pom.xml b/pitest-maven-verification/src/test/resources/pit-183-gwtmockito/pom.xml index 7dc23f19b..129890a0f 100644 --- a/pitest-maven-verification/src/test/resources/pit-183-gwtmockito/pom.xml +++ b/pitest-maven-verification/src/test/resources/pit-183-gwtmockito/pom.xml @@ -50,8 +50,8 @@ org.mockito - mockito-all - 1.10.19 + mockito-core + 3.3.3 test diff --git a/pitest-maven-verification/src/test/resources/pit-183-gwtmockito/src/test/java/sample/MyWidgetTest.java b/pitest-maven-verification/src/test/resources/pit-183-gwtmockito/src/test/java/sample/MyWidgetTest.java index ae7f9ac39..463e166de 100644 --- a/pitest-maven-verification/src/test/resources/pit-183-gwtmockito/src/test/java/sample/MyWidgetTest.java +++ b/pitest-maven-verification/src/test/resources/pit-183-gwtmockito/src/test/java/sample/MyWidgetTest.java @@ -17,7 +17,7 @@ import static com.google.gwtmockito.AsyncAnswers.returnSuccess; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; diff --git a/pitest-maven/src/test/java/org/pitest/maven/BasePitMojoTest.java b/pitest-maven/src/test/java/org/pitest/maven/BasePitMojoTest.java index 22cae3526..f2a646852 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/BasePitMojoTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/BasePitMojoTest.java @@ -22,7 +22,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.function.Function; import java.util.function.Predicate; import org.apache.maven.artifact.Artifact; @@ -61,7 +60,7 @@ protected void setUp() throws Exception { super.setUp(); MockitoAnnotations.initMocks(this); this.classPath = new ArrayList<>(FCollection.map( - ClassPath.getClassPathElementsAsFiles(), fileToString())); + ClassPath.getClassPathElementsAsFiles(), File::getAbsolutePath)); when(this.project.getTestClasspathElements()).thenReturn(this.classPath); when(this.project.getPackaging()).thenReturn("jar"); @@ -76,17 +75,6 @@ protected void setUp() throws Exception { Collections.emptyList()); } - private Function fileToString() { - return new Function() { - - @Override - public String apply(final File a) { - return a.getAbsolutePath(); - } - - }; - } - protected String createPomWithConfiguration(final String config) { final String pom = "\n" + // " \n" + // diff --git a/pitest-maven/src/test/java/org/pitest/maven/MojoToReportOptionsConverterTest.java b/pitest-maven/src/test/java/org/pitest/maven/MojoToReportOptionsConverterTest.java index 1543fcbe7..498fa1346 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/MojoToReportOptionsConverterTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/MojoToReportOptionsConverterTest.java @@ -16,7 +16,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.AdditionalAnswers.returnsFirstArg; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.isNull; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -376,7 +377,7 @@ public void testParsesExcludedClasspathElements() public void testParsesSurefireConfigWhenFlagSet() { parseConfig("true"); verify(this.surefireConverter).update(any(ReportOptions.class), - any(Xpp3Dom.class)); + isNull()); } public void testIgnoreSurefireConfigWhenFlagNotSet() { diff --git a/pitest-maven/src/test/java/org/pitest/maven/NonEmptyProjectCheckIT.java b/pitest-maven/src/test/java/org/pitest/maven/NonEmptyProjectCheckIT.java index 6ad83f0a6..64d464a39 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/NonEmptyProjectCheckIT.java +++ b/pitest-maven/src/test/java/org/pitest/maven/NonEmptyProjectCheckIT.java @@ -13,7 +13,7 @@ import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @Category(SystemTest.class) @RunWith(MockitoJUnitRunner.class) diff --git a/pitest-maven/src/test/java/org/pitest/maven/PitMojoTest.java b/pitest-maven/src/test/java/org/pitest/maven/PitMojoTest.java index f9f911390..7cc4a971f 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/PitMojoTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/PitMojoTest.java @@ -1,19 +1,19 @@ package org.pitest.maven; import static java.util.Arrays.asList; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.ArgumentMatchers.isNull; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.io.File; import java.util.Collections; -import java.util.Map; import org.apache.maven.model.Build; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.mockito.Matchers; import org.pitest.coverage.CoverageSummary; import org.pitest.mutationtest.config.PluginServices; import org.pitest.mutationtest.config.ReportOptions; @@ -37,7 +37,7 @@ public void testRunsAMutationReportWhenMutationCoverageGoalTrigered() build.setOutputDirectory("foo"); this.testee.getProject().setBuild(build); this.testee.execute(); - verify(this.executionStrategy).execute(any(File.class), + verify(this.executionStrategy).execute(isNull(), any(ReportOptions.class), any(PluginServices.class), anyMap()); } @@ -381,7 +381,7 @@ private void setupCoverage(long mutationScore, int lines, int linesCovered) CoverageSummary sum = new CoverageSummary(lines, linesCovered); final CombinedStatistics cs = new CombinedStatistics(stats, sum); when( - this.executionStrategy.execute(any(File.class), + this.executionStrategy.execute(isNull(), any(ReportOptions.class), any(PluginServices.class), anyMap())) .thenReturn(cs); } @@ -394,13 +394,9 @@ private void setupSuvivingMutants(long survivors) CoverageSummary sum = new CoverageSummary(0, 0); final CombinedStatistics cs = new CombinedStatistics(stats, sum); when( - this.executionStrategy.execute(any(File.class), + this.executionStrategy.execute(isNull(), any(ReportOptions.class), any(PluginServices.class), anyMap())) .thenReturn(cs); } - private Map anyMap() { - return Matchers.> any(); - } - } diff --git a/pitest-maven/src/test/java/org/pitest/maven/ScmMojoTest.java b/pitest-maven/src/test/java/org/pitest/maven/ScmMojoTest.java index 8d231f919..6fab59413 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/ScmMojoTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/ScmMojoTest.java @@ -1,6 +1,9 @@ package org.pitest.maven; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -10,7 +13,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.Date; -import java.util.Map; import org.apache.maven.model.Build; import org.apache.maven.model.Scm; @@ -27,7 +29,6 @@ import org.apache.maven.scm.command.status.StatusScmResult; import org.apache.maven.scm.manager.ScmManager; import org.apache.maven.scm.repository.ScmRepository; -import org.mockito.Matchers; import org.mockito.Mock; import org.pitest.mutationtest.config.PluginServices; import org.pitest.mutationtest.config.ReportOptions; @@ -61,7 +62,7 @@ public void setUp() throws Exception { when(this.build.getOutputDirectory()).thenReturn("foo"); when(this.build.getTestOutputDirectory()).thenReturn("foo"); when(this.project.getScm()).thenReturn(this.scm); - when(this.manager.makeScmRepository(any(String.class))).thenReturn( + when(this.manager.makeScmRepository(anyString())).thenReturn( this.repository); configurePitMojo(this.testee, createPomWithConfiguration("")); } @@ -102,7 +103,7 @@ public void testClassesAddedToScmAreMutationTested() throws Exception { setupConnection(); setFileWithStatus(ScmFileStatus.ADDED); this.testee.execute(); - verify(this.executionStrategy).execute(any(File.class), + verify(this.executionStrategy).execute(isNull(), any(ReportOptions.class), any(PluginServices.class), anyMap()); } @@ -118,7 +119,7 @@ public void testModifiedClassesAreMutationTested() throws Exception { setupConnection(); setFileWithStatus(ScmFileStatus.MODIFIED); this.testee.execute(); - verify(this.executionStrategy).execute(any(File.class), + verify(this.executionStrategy).execute(isNull(), any(ReportOptions.class), any(PluginServices.class), anyMap()); } @@ -129,7 +130,7 @@ public void testLastCommitIsMutationTested() throws Exception { createPomWithConfiguration("true")); givenChangeLogWithLastCommit(); this.testee.execute(); - verify(this.executionStrategy).execute(any(File.class), + verify(this.executionStrategy).execute(isNull(), any(ReportOptions.class), any(PluginServices.class), anyMap()); } @@ -169,7 +170,7 @@ public void testCanOverrideInspectedStatus() throws Exception { this.testee, createPomWithConfiguration("DELETEDUNKNOWN")); this.testee.execute(); - verify(this.executionStrategy, times(1)).execute(any(File.class), + verify(this.executionStrategy, times(1)).execute(isNull(), any(ReportOptions.class), any(PluginServices.class), anyMap()); } @@ -192,7 +193,4 @@ private void setupToReturnNoModifiedFiles() throws ScmException { .thenReturn(new StatusScmResult("", Collections. emptyList())); } - private Map anyMap() { - return Matchers.> any(); - } } \ No newline at end of file diff --git a/pitest-maven/src/test/java/org/pitest/maven/report/PitReportMojoTest.java b/pitest-maven/src/test/java/org/pitest/maven/report/PitReportMojoTest.java index 5c6f44e62..b835f5567 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/report/PitReportMojoTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/report/PitReportMojoTest.java @@ -32,7 +32,7 @@ import org.mockito.Captor; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.pitest.maven.report.generator.ReportGenerationContext; import org.pitest.maven.report.generator.ReportGenerationManager; import org.pitest.util.PitError; diff --git a/pitest-maven/src/test/java/org/pitest/maven/report/ReportSourceLocatorTest.java b/pitest-maven/src/test/java/org/pitest/maven/report/ReportSourceLocatorTest.java index 909cf7f44..20b797d18 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/report/ReportSourceLocatorTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/report/ReportSourceLocatorTest.java @@ -16,7 +16,7 @@ import static org.hamcrest.CoreMatchers.sameInstance; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.isA; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/pitest-maven/src/test/java/org/pitest/maven/report/generator/ReportGenerationManagerTest.java b/pitest-maven/src/test/java/org/pitest/maven/report/generator/ReportGenerationManagerTest.java index a580ffb5e..9cad90989 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/report/generator/ReportGenerationManagerTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/report/generator/ReportGenerationManagerTest.java @@ -31,7 +31,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.pitest.maven.report.ReportSourceLocator; import org.pitest.util.PitError; diff --git a/pitest/src/test/java/org/pitest/TestJUnitConfiguration.java b/pitest/src/test/java/org/pitest/TestJUnitConfiguration.java index 1be0b7f4d..4998e607d 100644 --- a/pitest/src/test/java/org/pitest/TestJUnitConfiguration.java +++ b/pitest/src/test/java/org/pitest/TestJUnitConfiguration.java @@ -3,7 +3,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import static org.junit.Assume.assumeTrue; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; diff --git a/pitest/src/test/java/org/pitest/bytecode/MethodDecoratorTest.java b/pitest/src/test/java/org/pitest/bytecode/MethodDecoratorTest.java index d65e1af16..0c078899c 100644 --- a/pitest/src/test/java/org/pitest/bytecode/MethodDecoratorTest.java +++ b/pitest/src/test/java/org/pitest/bytecode/MethodDecoratorTest.java @@ -14,8 +14,8 @@ */ package org.pitest.bytecode; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; import static org.objectweb.asm.Opcodes.NOP; diff --git a/pitest/src/test/java/org/pitest/classinfo/RepositoryTest.java b/pitest/src/test/java/org/pitest/classinfo/RepositoryTest.java index 81f79a857..4b7fb6f3b 100644 --- a/pitest/src/test/java/org/pitest/classinfo/RepositoryTest.java +++ b/pitest/src/test/java/org/pitest/classinfo/RepositoryTest.java @@ -17,8 +17,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; diff --git a/pitest/src/test/java/org/pitest/classpath/ClassPathTest.java b/pitest/src/test/java/org/pitest/classpath/ClassPathTest.java index b57d89183..2937ef9af 100644 --- a/pitest/src/test/java/org/pitest/classpath/ClassPathTest.java +++ b/pitest/src/test/java/org/pitest/classpath/ClassPathTest.java @@ -16,8 +16,8 @@ import static java.util.function.Predicate.isEqual; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyInt; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; diff --git a/pitest/src/test/java/org/pitest/classpath/CompoundClassPathRootTest.java b/pitest/src/test/java/org/pitest/classpath/CompoundClassPathRootTest.java index 7f66ca761..c3e7d2e31 100644 --- a/pitest/src/test/java/org/pitest/classpath/CompoundClassPathRootTest.java +++ b/pitest/src/test/java/org/pitest/classpath/CompoundClassPathRootTest.java @@ -1,7 +1,7 @@ package org.pitest.classpath; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; diff --git a/pitest/src/test/java/org/pitest/containers/TestContainersSendCorrectNotifications.java b/pitest/src/test/java/org/pitest/containers/TestContainersSendCorrectNotifications.java index 2b93e049f..41ae05f47 100644 --- a/pitest/src/test/java/org/pitest/containers/TestContainersSendCorrectNotifications.java +++ b/pitest/src/test/java/org/pitest/containers/TestContainersSendCorrectNotifications.java @@ -14,7 +14,7 @@ */ package org.pitest.containers; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import java.util.Arrays; diff --git a/pitest/src/test/java/org/pitest/coverage/codeassist/LineMapperTest.java b/pitest/src/test/java/org/pitest/coverage/codeassist/LineMapperTest.java index 2aa17d2c3..c570ec57f 100644 --- a/pitest/src/test/java/org/pitest/coverage/codeassist/LineMapperTest.java +++ b/pitest/src/test/java/org/pitest/coverage/codeassist/LineMapperTest.java @@ -1,7 +1,7 @@ package org.pitest.coverage.codeassist; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; import java.util.Map; @@ -10,7 +10,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.pitest.classinfo.ClassName; import org.pitest.classpath.CodeSource; import org.pitest.coverage.BlockLocation; diff --git a/pitest/src/test/java/org/pitest/coverage/execute/DependencyFilterTest.java b/pitest/src/test/java/org/pitest/coverage/execute/DependencyFilterTest.java index 35d69f4bc..d39cbe725 100644 --- a/pitest/src/test/java/org/pitest/coverage/execute/DependencyFilterTest.java +++ b/pitest/src/test/java/org/pitest/coverage/execute/DependencyFilterTest.java @@ -2,9 +2,10 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertSame; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.isNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -64,13 +65,13 @@ public void shouldNotPerformAnalysisWhenDependencyDistanceIsLessThan0() public void shouldReturnOnlyTestUnitsForClassesWithinReach() throws IOException { when( - this.extractor.extractCallDependenciesForPackages(eq(this.aTestUnit - .getDescription().getFirstTestClass()), any(Predicate.class))) - .thenReturn(Arrays.asList("foo")); + this.extractor.extractCallDependenciesForPackages( + eq(this.aTestUnit.getDescription().getFirstTestClass()), + isNull())).thenReturn(Arrays.asList("foo")); when( this.extractor.extractCallDependenciesForPackages( eq(this.anotherTestUnit.getDescription().getFirstTestClass()), - any(Predicate.class))).thenReturn(Collections. emptyList()); + isNull())).thenReturn(Collections. emptyList()); assertEquals(Arrays.asList(this.aTestUnit), this.testee.filterTestsByDependencyAnalysis(this.tus)); @@ -91,7 +92,7 @@ public void shouldNotRecalculateDependenciesForAlreadyAnalysedClasses() this.testee.filterTestsByDependencyAnalysis(this.tus); verify(this.extractor, times(1)).extractCallDependenciesForPackages( eq(this.aTestUnit.getDescription().getFirstTestClass()), - any(Predicate.class)); + isNull()); } private TestUnit makeTestUnit(final Description d) { diff --git a/pitest/src/test/java/org/pitest/junit/adapter/AdaptedJUnitTestUnitTest.java b/pitest/src/test/java/org/pitest/junit/adapter/AdaptedJUnitTestUnitTest.java index 8149e0374..38b4175cb 100644 --- a/pitest/src/test/java/org/pitest/junit/adapter/AdaptedJUnitTestUnitTest.java +++ b/pitest/src/test/java/org/pitest/junit/adapter/AdaptedJUnitTestUnitTest.java @@ -15,8 +15,8 @@ package org.pitest.junit.adapter; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; import org.junit.Before; diff --git a/pitest/src/test/java/org/pitest/junit/adapter/CustomRunnerExecutorTest.java b/pitest/src/test/java/org/pitest/junit/adapter/CustomRunnerExecutorTest.java index 57a5cddb6..411d8fd9e 100644 --- a/pitest/src/test/java/org/pitest/junit/adapter/CustomRunnerExecutorTest.java +++ b/pitest/src/test/java/org/pitest/junit/adapter/CustomRunnerExecutorTest.java @@ -15,7 +15,7 @@ package org.pitest.junit.adapter; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import org.junit.Before; diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/AvoidAssertsMethodAdapterTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/AvoidAssertsMethodAdapterTest.java index 8d3997298..03cab3b65 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/AvoidAssertsMethodAdapterTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/AvoidAssertsMethodAdapterTest.java @@ -1,6 +1,6 @@ package org.pitest.mutationtest.engine.gregor; -import static org.mockito.Matchers.anyString; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/AvoidStringSwitchedMethodAdapterTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/AvoidStringSwitchedMethodAdapterTest.java index f799678b7..9aece86aa 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/AvoidStringSwitchedMethodAdapterTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/AvoidStringSwitchedMethodAdapterTest.java @@ -1,6 +1,6 @@ package org.pitest.mutationtest.engine.gregor; -import static org.mockito.Matchers.anyString; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; diff --git a/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestMinionTest.java b/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestMinionTest.java index fd85e7bf5..a490782a9 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestMinionTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestMinionTest.java @@ -1,6 +1,6 @@ package org.pitest.mutationtest.execute; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.pitest.mutationtest.LocationMother.aMutationId; diff --git a/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestWorkerTest.java b/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestWorkerTest.java index 026832751..ff6a19b53 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestWorkerTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestWorkerTest.java @@ -1,6 +1,6 @@ package org.pitest.mutationtest.execute; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.pitest.mutationtest.LocationMother.aLocation; diff --git a/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTimeoutDecoratorTest.java b/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTimeoutDecoratorTest.java index c2d3d1646..397ad26d1 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTimeoutDecoratorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTimeoutDecoratorTest.java @@ -14,7 +14,7 @@ */ package org.pitest.mutationtest.execute; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; diff --git a/pitest/src/test/java/org/pitest/mutationtest/mocksupport/BendJavassistToMyWillTransformerTest.java b/pitest/src/test/java/org/pitest/mutationtest/mocksupport/BendJavassistToMyWillTransformerTest.java index 793ca92e9..758bacc7c 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/mocksupport/BendJavassistToMyWillTransformerTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/mocksupport/BendJavassistToMyWillTransformerTest.java @@ -2,7 +2,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; import java.lang.instrument.IllegalClassFormatException; diff --git a/pitest/src/test/java/org/pitest/testapi/execute/TestPitest.java b/pitest/src/test/java/org/pitest/testapi/execute/TestPitest.java index 9a45cc683..eab629c21 100644 --- a/pitest/src/test/java/org/pitest/testapi/execute/TestPitest.java +++ b/pitest/src/test/java/org/pitest/testapi/execute/TestPitest.java @@ -1,6 +1,6 @@ package org.pitest.testapi.execute; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import java.io.FileNotFoundException; diff --git a/pitest/src/test/java/org/pitest/testng/TestNGTestUnitTest.java b/pitest/src/test/java/org/pitest/testng/TestNGTestUnitTest.java index 1d86c63ff..bb746e4b0 100644 --- a/pitest/src/test/java/org/pitest/testng/TestNGTestUnitTest.java +++ b/pitest/src/test/java/org/pitest/testng/TestNGTestUnitTest.java @@ -14,8 +14,8 @@ */ package org.pitest.testng; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -39,8 +39,6 @@ import com.example.testng.Passes; import com.example.testng.Skips; -import junit.framework.AssertionFailedError; - public class TestNGTestUnitTest { @Mock @@ -88,7 +86,7 @@ public void shouldReportTestEndWithThrowableWhenTestFails() { this.testee.execute(this.rc); verify(this.rc, times(1)).notifyEnd( eq(new Description("fails", Fails.class)), - any(AssertionFailedError.class)); + any(AssertionError.class)); } @Test diff --git a/pitest/src/test/java/org/pitest/util/CachingByteArraySourceTest.java b/pitest/src/test/java/org/pitest/util/CachingByteArraySourceTest.java index 273cd6ea6..ce9f05e9f 100644 --- a/pitest/src/test/java/org/pitest/util/CachingByteArraySourceTest.java +++ b/pitest/src/test/java/org/pitest/util/CachingByteArraySourceTest.java @@ -8,7 +8,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.pitest.classinfo.CachingByteArraySource; import org.pitest.classinfo.ClassByteArraySource; import java.util.Optional; diff --git a/pom.xml b/pom.xml index a5fc2d711..7f17a6e46 100644 --- a/pom.xml +++ b/pom.xml @@ -143,8 +143,8 @@ org.mockito - mockito-all - 1.9.5 + mockito-core + 3.3.3 test From 23013c01e33fb5a9ecdb24cd85d76442d7d7ffaf Mon Sep 17 00:00:00 2001 From: Alexey Elin Date: Fri, 8 May 2020 21:08:20 +0300 Subject: [PATCH 2/5] fix stubbing --- .../config/CompoundListenerFactoryTest.java | 14 ++++++++++---- .../incremental/IncrementalAnalyserTest.java | 5 +++-- .../coverage/execute/DependencyFilterTest.java | 9 ++++----- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/config/CompoundListenerFactoryTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/config/CompoundListenerFactoryTest.java index fc585f6c7..f990fd1a8 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/config/CompoundListenerFactoryTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/config/CompoundListenerFactoryTest.java @@ -14,18 +14,20 @@ */ package org.pitest.mutationtest.config; -import static org.mockito.ArgumentMatchers.isNull; +import static org.mockito.Mockito.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.util.Arrays; +import java.util.Properties; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.pitest.mutationtest.ListenerArguments; import org.pitest.mutationtest.MutationResultListener; import org.pitest.mutationtest.MutationResultListenerFactory; @@ -50,9 +52,13 @@ public void setUp() { public void shouldCreateACombinedListenerForAllChildFactories() { final MutationResultListener listenerOne = mock(MutationResultListener.class); final MutationResultListener listenerTwo = mock(MutationResultListener.class); - when(this.firstChild.getListener(isNull(), isNull())).thenReturn(listenerOne); - when(this.secondChild.getListener(isNull(), isNull())).thenReturn(listenerTwo); - this.testee.getListener(null, null).runStart(); + when( + this.firstChild.getListener(any(Properties.class), + any(ListenerArguments.class))).thenReturn(listenerOne); + when( + this.secondChild.getListener(any(Properties.class), + any(ListenerArguments.class))).thenReturn(listenerTwo); + this.testee.getListener(new Properties(), mock(ListenerArguments.class)).runStart(); verify(listenerOne, times(1)).runStart(); verify(listenerTwo, times(1)).runStart(); } diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/IncrementalAnalyserTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/IncrementalAnalyserTest.java index 8e5170e95..ae77b207c 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/IncrementalAnalyserTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/IncrementalAnalyserTest.java @@ -1,7 +1,6 @@ package org.pitest.mutationtest.incremental; import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; import static org.pitest.mutationtest.LocationMother.aLocation; @@ -58,9 +57,11 @@ public void shouldStartNewMutationsAtAStatusOfNotStarted() { public void shouldStartPreviousSurvivedMutationsAtAStatusOfNotStartedWhenCoverageHasChanged() { final MutationDetails md = makeMutation("foo"); setHistoryForAllMutationsTo(DetectionStatus.SURVIVED); + when(coverage.getCoverageIdForClass(any(ClassName.class))) + .thenReturn(BigInteger.ONE); when( this.history.hasCoverageChanged(any(ClassName.class), - isNull())).thenReturn(true); + any(BigInteger.class))).thenReturn(true); final Collection actual = this.testee.analyse(Collections .singletonList(md)); assertEquals(DetectionStatus.NOT_STARTED, actual.iterator().next() diff --git a/pitest/src/test/java/org/pitest/coverage/execute/DependencyFilterTest.java b/pitest/src/test/java/org/pitest/coverage/execute/DependencyFilterTest.java index d39cbe725..dfca8e814 100644 --- a/pitest/src/test/java/org/pitest/coverage/execute/DependencyFilterTest.java +++ b/pitest/src/test/java/org/pitest/coverage/execute/DependencyFilterTest.java @@ -2,7 +2,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertSame; -import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -46,7 +45,7 @@ public void setUp() { this.aTestUnit = makeTestUnit(new Description("foo", String.class)); this.anotherTestUnit = makeTestUnit(new Description("bar", Integer.class)); - this.testee = new DependencyFilter(this.extractor, null); + this.testee = new DependencyFilter(this.extractor, s -> true); this.tus = Arrays.asList(this.aTestUnit, this.anotherTestUnit); } @@ -67,11 +66,11 @@ public void shouldReturnOnlyTestUnitsForClassesWithinReach() when( this.extractor.extractCallDependenciesForPackages( eq(this.aTestUnit.getDescription().getFirstTestClass()), - isNull())).thenReturn(Arrays.asList("foo")); + any(Predicate.class))).thenReturn(Arrays.asList("foo")); when( this.extractor.extractCallDependenciesForPackages( eq(this.anotherTestUnit.getDescription().getFirstTestClass()), - isNull())).thenReturn(Collections. emptyList()); + any(Predicate.class))).thenReturn(Collections. emptyList()); assertEquals(Arrays.asList(this.aTestUnit), this.testee.filterTestsByDependencyAnalysis(this.tus)); @@ -92,7 +91,7 @@ public void shouldNotRecalculateDependenciesForAlreadyAnalysedClasses() this.testee.filterTestsByDependencyAnalysis(this.tus); verify(this.extractor, times(1)).extractCallDependenciesForPackages( eq(this.aTestUnit.getDescription().getFirstTestClass()), - isNull()); + any(Predicate.class)); } private TestUnit makeTestUnit(final Description d) { From d36f62ada91a5a85fb8286468b63f7a9a4962616 Mon Sep 17 00:00:00 2001 From: Alexey Elin Date: Mon, 19 Oct 2020 17:11:14 +0300 Subject: [PATCH 3/5] fix failing test + up mockito version --- pitest-maven/src/test/java/org/pitest/maven/PitMojoTest.java | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pitest-maven/src/test/java/org/pitest/maven/PitMojoTest.java b/pitest-maven/src/test/java/org/pitest/maven/PitMojoTest.java index 364f265cc..06d5b8d46 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/PitMojoTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/PitMojoTest.java @@ -405,7 +405,7 @@ private void setupTestStrength(long totalMutations, long mutationDetected, long CoverageSummary sum = new CoverageSummary(0, 0); final CombinedStatistics cs = new CombinedStatistics(stats, sum); when( - this.executionStrategy.execute(any(File.class), + this.executionStrategy.execute(isNull(), any(ReportOptions.class), any(PluginServices.class), anyMap())) .thenReturn(cs); } diff --git a/pom.xml b/pom.xml index ecc56b345..c3eca2076 100644 --- a/pom.xml +++ b/pom.xml @@ -144,7 +144,7 @@ org.mockito mockito-core - 3.3.3 + 3.5.13 test From f4f1dd784c2fb78f72ef73919c46d09a7ef7dd84 Mon Sep 17 00:00:00 2001 From: Alexey Elin Date: Tue, 8 Dec 2020 11:39:35 +0300 Subject: [PATCH 4/5] update Mockito and replace deprecated initMocks with openMocks --- .../pitest/mutationtest/commandline/OptionsParserTest.java | 2 +- .../src/test/java/org/pitest/classinfo/RepositoryTest.java | 2 +- .../test/java/org/pitest/classinfo/TestToClassMapperTest.java | 2 +- .../src/test/java/org/pitest/coverage/CoverageDataTest.java | 2 +- .../test/java/org/pitest/coverage/execute/ReceiveTest.java | 2 +- .../test/java/org/pitest/coverage/execute/SendDataTest.java | 2 +- .../java/org/pitest/mutationtest/TestMutationTesting.java | 2 +- .../pitest/mutationtest/build/DefaultTestPrioritiserTest.java | 2 +- .../mutationtest/build/KnownStatusMutationTestUnitTest.java | 2 +- .../pitest/mutationtest/build/MutationTestBuilderTest.java | 2 +- .../org/pitest/mutationtest/build/MutationTestUnitTest.java | 2 +- .../mutationtest/config/CompoundListenerFactoryTest.java | 2 +- .../pitest/mutationtest/config/CompoundTestListenerTest.java | 2 +- .../mutationtest/incremental/DefaultCodeHistoryTest.java | 2 +- .../pitest/mutationtest/incremental/HistoryListenerTest.java | 2 +- .../mutationtest/incremental/IncrementalAnalyserTest.java | 2 +- .../incremental/ObjectOutputStreamHistoryStoreTest.java | 4 ++-- .../pitest/mutationtest/report/csv/CSVReportListenerTest.java | 2 +- .../mutationtest/tooling/DirectorySourceLocatorTest.java | 2 +- .../pitest/mutationtest/tooling/JarCreatingJarFinderTest.java | 2 +- .../mutationtest/tooling/MutationCoverageReportTest.java | 2 +- .../pitest/mutationtest/verify/DefaultBuildVerifierTest.java | 2 +- .../test/java/org/pitest/util/SocketReadingCallableTest.java | 2 +- .../report/html/MutationHtmlReportListenerTest.java | 2 +- .../src/test/java/org/pitest/maven/BasePitMojoTest.java | 2 +- .../src/test/java/org/pitest/maven/DependencyFilterIT.java | 2 +- .../maven/report/generator/ReportGenerationManagerTest.java | 4 ++-- pitest/src/test/java/org/pitest/TestJUnitConfiguration.java | 2 +- .../test/java/org/pitest/bytecode/MethodDecoratorTest.java | 2 +- pitest/src/test/java/org/pitest/classinfo/RepositoryTest.java | 2 +- .../test/java/org/pitest/classinfo/TestToClassMapperTest.java | 2 +- pitest/src/test/java/org/pitest/classpath/ClassPathTest.java | 2 +- pitest/src/test/java/org/pitest/classpath/CodeSourceTest.java | 2 +- .../java/org/pitest/classpath/CompoundClassPathRootTest.java | 2 +- .../containers/TestContainersSendCorrectNotifications.java | 4 ++-- .../java/org/pitest/coverage/CoverageTransformerTest.java | 2 +- .../org/pitest/coverage/execute/DependencyFilterTest.java | 2 +- .../org/pitest/junit/JUnitCustomRunnerTestUnitFinderTest.java | 2 +- .../org/pitest/junit/adapter/AdaptedJUnitTestUnitTest.java | 2 +- .../org/pitest/junit/adapter/AdaptingRunListenerTest.java | 2 +- .../org/pitest/junit/adapter/CustomRunnerExecutorTest.java | 2 +- .../pitest/mutationtest/execute/MutationTestMinionTest.java | 2 +- .../pitest/mutationtest/execute/MutationTestWorkerTest.java | 2 +- .../mutationtest/execute/MutationTimeoutDecoratorTest.java | 2 +- .../mutationtest/execute/TimeOutDecoratedTestSourceTest.java | 2 +- .../mutationtest/execute/TimeOutSystemExitSideEffectTest.java | 2 +- .../mocksupport/BendJavassistToMyWillTransformerTest.java | 2 +- .../JavassistInputStreamInterceptorAdapaterTest.java | 2 +- .../pitest/testapi/execute/ExitingResultCollectorTest.java | 2 +- .../org/pitest/testapi/execute/MultipleTestGroupTest.java | 2 +- .../test/java/org/pitest/testapi/execute/ResultTypeTest.java | 2 +- .../src/test/java/org/pitest/testapi/execute/TestPitest.java | 2 +- pitest/src/test/java/org/pitest/testng/TestNGAdapterTest.java | 2 +- .../src/test/java/org/pitest/testng/TestNGTestUnitTest.java | 2 +- pitest/src/test/java/sun/pitest/CodeCoverageStoreTest.java | 2 +- pom.xml | 2 +- 56 files changed, 59 insertions(+), 59 deletions(-) diff --git a/pitest-command-line/src/test/java/org/pitest/mutationtest/commandline/OptionsParserTest.java b/pitest-command-line/src/test/java/org/pitest/mutationtest/commandline/OptionsParserTest.java index eb75cb6c6..bef0cb635 100644 --- a/pitest-command-line/src/test/java/org/pitest/mutationtest/commandline/OptionsParserTest.java +++ b/pitest-command-line/src/test/java/org/pitest/mutationtest/commandline/OptionsParserTest.java @@ -56,7 +56,7 @@ public class OptionsParserTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); when(this.filter.test(any(String.class))).thenReturn(true); this.testee = new OptionsParser(this.filter); } diff --git a/pitest-entry/src/test/java/org/pitest/classinfo/RepositoryTest.java b/pitest-entry/src/test/java/org/pitest/classinfo/RepositoryTest.java index 4b7fb6f3b..2bf1b8ff0 100644 --- a/pitest-entry/src/test/java/org/pitest/classinfo/RepositoryTest.java +++ b/pitest-entry/src/test/java/org/pitest/classinfo/RepositoryTest.java @@ -47,7 +47,7 @@ public class RepositoryTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new Repository(new ClassloaderByteArraySource( IsolationUtils.getContextClassLoader()), this.hashFunction); } diff --git a/pitest-entry/src/test/java/org/pitest/classinfo/TestToClassMapperTest.java b/pitest-entry/src/test/java/org/pitest/classinfo/TestToClassMapperTest.java index 3fc78f01e..e2e2609d0 100644 --- a/pitest-entry/src/test/java/org/pitest/classinfo/TestToClassMapperTest.java +++ b/pitest-entry/src/test/java/org/pitest/classinfo/TestToClassMapperTest.java @@ -34,7 +34,7 @@ public class TestToClassMapperTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.repository = new Repository(this.source); this.testee = new TestToClassMapper(this.repository); } diff --git a/pitest-entry/src/test/java/org/pitest/coverage/CoverageDataTest.java b/pitest-entry/src/test/java/org/pitest/coverage/CoverageDataTest.java index 81388cfc0..5363866cc 100644 --- a/pitest-entry/src/test/java/org/pitest/coverage/CoverageDataTest.java +++ b/pitest-entry/src/test/java/org/pitest/coverage/CoverageDataTest.java @@ -65,7 +65,7 @@ public class CoverageDataTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); when(this.lm.mapLines(any(ClassName.class))).thenReturn( new HashMap>()); when(this.code.findTestee(any())).thenReturn(Optional.empty()); diff --git a/pitest-entry/src/test/java/org/pitest/coverage/execute/ReceiveTest.java b/pitest-entry/src/test/java/org/pitest/coverage/execute/ReceiveTest.java index 2667fb619..6f637eb24 100644 --- a/pitest-entry/src/test/java/org/pitest/coverage/execute/ReceiveTest.java +++ b/pitest-entry/src/test/java/org/pitest/coverage/execute/ReceiveTest.java @@ -33,7 +33,7 @@ public class ReceiveTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.handler = stubHandler(); this.testee = new Receive(this.handler); this.description = new Description("foo", "bar"); diff --git a/pitest-entry/src/test/java/org/pitest/coverage/execute/SendDataTest.java b/pitest-entry/src/test/java/org/pitest/coverage/execute/SendDataTest.java index 8af6d6bf2..2c6cefaa8 100644 --- a/pitest-entry/src/test/java/org/pitest/coverage/execute/SendDataTest.java +++ b/pitest-entry/src/test/java/org/pitest/coverage/execute/SendDataTest.java @@ -25,7 +25,7 @@ public class SendDataTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testClasses = new ArrayList<>(); this.testee = new SendData(this.arguments, this.testClasses); } diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/TestMutationTesting.java b/pitest-entry/src/test/java/org/pitest/mutationtest/TestMutationTesting.java index 83cb05c0e..7457e20dc 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/TestMutationTesting.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/TestMutationTesting.java @@ -88,7 +88,7 @@ public class TestMutationTesting { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.config = TestPluginArguments.defaults().withTestPlugin(SimpleTestPlugin.NAME); this.metaDataExtractor = new MetaDataExtractor(); this.mae = new MutationAnalysisExecutor(1, diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/build/DefaultTestPrioritiserTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/build/DefaultTestPrioritiserTest.java index 155e14a8c..3b30e097c 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/build/DefaultTestPrioritiserTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/build/DefaultTestPrioritiserTest.java @@ -39,7 +39,7 @@ public class DefaultTestPrioritiserTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new DefaultTestPrioritiser(this.coverage); } diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/build/KnownStatusMutationTestUnitTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/build/KnownStatusMutationTestUnitTest.java index 5be3aa8ea..c0979cc96 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/build/KnownStatusMutationTestUnitTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/build/KnownStatusMutationTestUnitTest.java @@ -22,7 +22,7 @@ public class KnownStatusMutationTestUnitTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); } diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/build/MutationTestBuilderTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/build/MutationTestBuilderTest.java index 31279e812..f288fad5a 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/build/MutationTestBuilderTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/build/MutationTestBuilderTest.java @@ -31,7 +31,7 @@ public class MutationTestBuilderTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); makeTesteeWithUnitSizeOf(0); } diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/build/MutationTestUnitTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/build/MutationTestUnitTest.java index c339e005e..2ed7914b9 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/build/MutationTestUnitTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/build/MutationTestUnitTest.java @@ -49,7 +49,7 @@ public class MutationTestUnitTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.mutationConfig = new MutationConfig(this.engine, new LaunchOptions( this.javaAgent)); this.mutations = new ArrayList<>(); diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/config/CompoundListenerFactoryTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/config/CompoundListenerFactoryTest.java index f990fd1a8..ce078f35f 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/config/CompoundListenerFactoryTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/config/CompoundListenerFactoryTest.java @@ -43,7 +43,7 @@ public class CompoundListenerFactoryTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new CompoundListenerFactory(Arrays.asList(this.firstChild, this.secondChild)); } diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/config/CompoundTestListenerTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/config/CompoundTestListenerTest.java index 8d14fd54c..e20dd489d 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/config/CompoundTestListenerTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/config/CompoundTestListenerTest.java @@ -40,7 +40,7 @@ public class CompoundTestListenerTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new CompoundTestListener(Arrays.asList(this.firstChild, this.secondChild)); } diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/DefaultCodeHistoryTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/DefaultCodeHistoryTest.java index c1298b78b..6137fdd70 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/DefaultCodeHistoryTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/DefaultCodeHistoryTest.java @@ -38,7 +38,7 @@ public class DefaultCodeHistoryTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new DefaultCodeHistory(this.classInfoSource, this.results, this.historicClassPath); } diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/HistoryListenerTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/HistoryListenerTest.java index 5ace77889..dbb189854 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/HistoryListenerTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/HistoryListenerTest.java @@ -22,7 +22,7 @@ public class HistoryListenerTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new HistoryListener(this.store); } diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/IncrementalAnalyserTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/IncrementalAnalyserTest.java index c348f02b6..573a845db 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/IncrementalAnalyserTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/IncrementalAnalyserTest.java @@ -69,7 +69,7 @@ public void configureLogCatcher() { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new IncrementalAnalyser(this.history, this.coverage); } diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/ObjectOutputStreamHistoryStoreTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/ObjectOutputStreamHistoryStoreTest.java index 8804da1ce..1e8ae6ca6 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/ObjectOutputStreamHistoryStoreTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/incremental/ObjectOutputStreamHistoryStoreTest.java @@ -62,7 +62,7 @@ public void close() { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); when(this.coverage.getCoverageIdForClass(any(ClassName.class))).thenReturn( BigInteger.TEN); } @@ -148,4 +148,4 @@ private void recordClassPathWithTestee( this.testee.recordClassPath(ids, this.coverage); } -} \ No newline at end of file +} diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/report/csv/CSVReportListenerTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/report/csv/CSVReportListenerTest.java index 8cac8c026..7eeae4f8e 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/report/csv/CSVReportListenerTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/report/csv/CSVReportListenerTest.java @@ -39,7 +39,7 @@ public class CSVReportListenerTest { @Before public void setup() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new CSVReportListener(this.out); } diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/DirectorySourceLocatorTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/DirectorySourceLocatorTest.java index 7660c91f7..0f1ce82e3 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/DirectorySourceLocatorTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/DirectorySourceLocatorTest.java @@ -39,7 +39,7 @@ public class DirectorySourceLocatorTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.root = new File("."); this.testee = new DirectorySourceLocator(this.root, this.locator); when(this.locator.apply(any(File.class))) diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/JarCreatingJarFinderTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/JarCreatingJarFinderTest.java index 8e808830b..049e26b58 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/JarCreatingJarFinderTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/JarCreatingJarFinderTest.java @@ -51,7 +51,7 @@ public class JarCreatingJarFinderTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); when(this.byteSource.getBytes(anyString())).thenReturn( Optional.ofNullable(new byte[1])); this.testee = new JarCreatingJarFinder(this.byteSource); diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/MutationCoverageReportTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/MutationCoverageReportTest.java index 03f12f268..9f29c39e4 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/MutationCoverageReportTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/tooling/MutationCoverageReportTest.java @@ -102,7 +102,7 @@ public class MutationCoverageReportTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.data = new ReportOptions(); this.data.setSourceDirs(Collections. emptyList()); when(this.coverage.calculateCoverage()).thenReturn(this.coverageDb); diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/verify/DefaultBuildVerifierTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/verify/DefaultBuildVerifierTest.java index ca3254ef7..cdfa123a9 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/verify/DefaultBuildVerifierTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/verify/DefaultBuildVerifierTest.java @@ -43,7 +43,7 @@ public class DefaultBuildVerifierTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new DefaultBuildVerifier(); } diff --git a/pitest-entry/src/test/java/org/pitest/util/SocketReadingCallableTest.java b/pitest-entry/src/test/java/org/pitest/util/SocketReadingCallableTest.java index 6239bb297..38286a772 100644 --- a/pitest-entry/src/test/java/org/pitest/util/SocketReadingCallableTest.java +++ b/pitest-entry/src/test/java/org/pitest/util/SocketReadingCallableTest.java @@ -40,7 +40,7 @@ public class SocketReadingCallableTest { @Before public void setUp() throws IOException { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new SocketReadingCallable(this.socket, this.sendDataSideEffect, this.receiveStrategy); diff --git a/pitest-html-report/src/test/java/org/pitest/mutationtest/report/html/MutationHtmlReportListenerTest.java b/pitest-html-report/src/test/java/org/pitest/mutationtest/report/html/MutationHtmlReportListenerTest.java index 736bc4e4c..adc060499 100644 --- a/pitest-html-report/src/test/java/org/pitest/mutationtest/report/html/MutationHtmlReportListenerTest.java +++ b/pitest-html-report/src/test/java/org/pitest/mutationtest/report/html/MutationHtmlReportListenerTest.java @@ -60,7 +60,7 @@ public class MutationHtmlReportListenerTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); when(this.outputStrategy.createWriterForFile(any(String.class))) .thenReturn(this.writer); diff --git a/pitest-maven/src/test/java/org/pitest/maven/BasePitMojoTest.java b/pitest-maven/src/test/java/org/pitest/maven/BasePitMojoTest.java index f2a646852..246c1d1f0 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/BasePitMojoTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/BasePitMojoTest.java @@ -58,7 +58,7 @@ public abstract class BasePitMojoTest extends AbstractMojoTestCase { @Override protected void setUp() throws Exception { super.setUp(); - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.classPath = new ArrayList<>(FCollection.map( ClassPath.getClassPathElementsAsFiles(), File::getAbsolutePath)); when(this.project.getTestClasspathElements()).thenReturn(this.classPath); diff --git a/pitest-maven/src/test/java/org/pitest/maven/DependencyFilterIT.java b/pitest-maven/src/test/java/org/pitest/maven/DependencyFilterIT.java index 30dfc5d4d..0c0bab391 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/DependencyFilterIT.java +++ b/pitest-maven/src/test/java/org/pitest/maven/DependencyFilterIT.java @@ -36,7 +36,7 @@ public class DependencyFilterIT { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new DependencyFilter(PluginServices.makeForContextLoader()); } diff --git a/pitest-maven/src/test/java/org/pitest/maven/report/generator/ReportGenerationManagerTest.java b/pitest-maven/src/test/java/org/pitest/maven/report/generator/ReportGenerationManagerTest.java index 9cad90989..0ec42cb9c 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/report/generator/ReportGenerationManagerTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/report/generator/ReportGenerationManagerTest.java @@ -17,7 +17,7 @@ import static org.hamcrest.CoreMatchers.sameInstance; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; import java.io.File; @@ -85,7 +85,7 @@ public void testFirstGeneratorSuccess() { this.fixture.generateSiteReport(this.generationContext); verify(this.xmlGenerator).generate(this.generationContext); - verifyZeroInteractions(this.htmlGenerator); + verifyNoInteractions(this.htmlGenerator); this.assertLocatedReportsDirectory(); } diff --git a/pitest/src/test/java/org/pitest/TestJUnitConfiguration.java b/pitest/src/test/java/org/pitest/TestJUnitConfiguration.java index 4998e607d..a1d3ac758 100644 --- a/pitest/src/test/java/org/pitest/TestJUnitConfiguration.java +++ b/pitest/src/test/java/org/pitest/TestJUnitConfiguration.java @@ -64,7 +64,7 @@ public class TestJUnitConfiguration { @Before public void createTestee() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.container = new UnContainer(); this.pitest = new Pitest(this.listener); diff --git a/pitest/src/test/java/org/pitest/bytecode/MethodDecoratorTest.java b/pitest/src/test/java/org/pitest/bytecode/MethodDecoratorTest.java index 0c078899c..007de0cda 100644 --- a/pitest/src/test/java/org/pitest/bytecode/MethodDecoratorTest.java +++ b/pitest/src/test/java/org/pitest/bytecode/MethodDecoratorTest.java @@ -37,7 +37,7 @@ public abstract class MethodDecoratorTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); } @Test diff --git a/pitest/src/test/java/org/pitest/classinfo/RepositoryTest.java b/pitest/src/test/java/org/pitest/classinfo/RepositoryTest.java index 4b7fb6f3b..2bf1b8ff0 100644 --- a/pitest/src/test/java/org/pitest/classinfo/RepositoryTest.java +++ b/pitest/src/test/java/org/pitest/classinfo/RepositoryTest.java @@ -47,7 +47,7 @@ public class RepositoryTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new Repository(new ClassloaderByteArraySource( IsolationUtils.getContextClassLoader()), this.hashFunction); } diff --git a/pitest/src/test/java/org/pitest/classinfo/TestToClassMapperTest.java b/pitest/src/test/java/org/pitest/classinfo/TestToClassMapperTest.java index 3fc78f01e..e2e2609d0 100644 --- a/pitest/src/test/java/org/pitest/classinfo/TestToClassMapperTest.java +++ b/pitest/src/test/java/org/pitest/classinfo/TestToClassMapperTest.java @@ -34,7 +34,7 @@ public class TestToClassMapperTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.repository = new Repository(this.source); this.testee = new TestToClassMapper(this.repository); } diff --git a/pitest/src/test/java/org/pitest/classpath/ClassPathTest.java b/pitest/src/test/java/org/pitest/classpath/ClassPathTest.java index 2937ef9af..45930ee64 100644 --- a/pitest/src/test/java/org/pitest/classpath/ClassPathTest.java +++ b/pitest/src/test/java/org/pitest/classpath/ClassPathTest.java @@ -46,7 +46,7 @@ public class ClassPathTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new ClassPath(this.firstComponent, this.secondComponent); when(this.firstComponent.cacheLocation()).thenReturn(Optional.ofNullable("foo")); when(this.firstComponent.classNames()).thenReturn( diff --git a/pitest/src/test/java/org/pitest/classpath/CodeSourceTest.java b/pitest/src/test/java/org/pitest/classpath/CodeSourceTest.java index d11f79d9f..d86d70884 100644 --- a/pitest/src/test/java/org/pitest/classpath/CodeSourceTest.java +++ b/pitest/src/test/java/org/pitest/classpath/CodeSourceTest.java @@ -33,7 +33,7 @@ public class CodeSourceTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new CodeSource(this.classPath, this.repository); this.foo = makeClassInfo("Foo"); this.bar = makeClassInfo("Bar"); diff --git a/pitest/src/test/java/org/pitest/classpath/CompoundClassPathRootTest.java b/pitest/src/test/java/org/pitest/classpath/CompoundClassPathRootTest.java index c3e7d2e31..e9d47b7ea 100644 --- a/pitest/src/test/java/org/pitest/classpath/CompoundClassPathRootTest.java +++ b/pitest/src/test/java/org/pitest/classpath/CompoundClassPathRootTest.java @@ -33,7 +33,7 @@ public class CompoundClassPathRootTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new CompoundClassPathRoot(Arrays.asList(this.child1,this.heavyChild, this.child2)); } diff --git a/pitest/src/test/java/org/pitest/containers/TestContainersSendCorrectNotifications.java b/pitest/src/test/java/org/pitest/containers/TestContainersSendCorrectNotifications.java index 41ae05f47..009904793 100644 --- a/pitest/src/test/java/org/pitest/containers/TestContainersSendCorrectNotifications.java +++ b/pitest/src/test/java/org/pitest/containers/TestContainersSendCorrectNotifications.java @@ -69,7 +69,7 @@ private static Object uncontainerFactory() { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.config = new ConfigurationForTesting(); this.pit = new Pitest(this.listener); } @@ -106,4 +106,4 @@ private void run(final Class clazz) { this.pit.run(this.containerFactory.getContainer(), this.config, clazz); } -} \ No newline at end of file +} diff --git a/pitest/src/test/java/org/pitest/coverage/CoverageTransformerTest.java b/pitest/src/test/java/org/pitest/coverage/CoverageTransformerTest.java index 119831335..813aca88a 100644 --- a/pitest/src/test/java/org/pitest/coverage/CoverageTransformerTest.java +++ b/pitest/src/test/java/org/pitest/coverage/CoverageTransformerTest.java @@ -46,7 +46,7 @@ public class CoverageTransformerTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); CodeCoverageStore.init(this.invokeQueue); } diff --git a/pitest/src/test/java/org/pitest/coverage/execute/DependencyFilterTest.java b/pitest/src/test/java/org/pitest/coverage/execute/DependencyFilterTest.java index dfca8e814..a93f8da51 100644 --- a/pitest/src/test/java/org/pitest/coverage/execute/DependencyFilterTest.java +++ b/pitest/src/test/java/org/pitest/coverage/execute/DependencyFilterTest.java @@ -40,7 +40,7 @@ public class DependencyFilterTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.aTestUnit = makeTestUnit(new Description("foo", String.class)); this.anotherTestUnit = makeTestUnit(new Description("bar", Integer.class)); diff --git a/pitest/src/test/java/org/pitest/junit/JUnitCustomRunnerTestUnitFinderTest.java b/pitest/src/test/java/org/pitest/junit/JUnitCustomRunnerTestUnitFinderTest.java index 48c84cbd2..0b8f371a7 100644 --- a/pitest/src/test/java/org/pitest/junit/JUnitCustomRunnerTestUnitFinderTest.java +++ b/pitest/src/test/java/org/pitest/junit/JUnitCustomRunnerTestUnitFinderTest.java @@ -62,7 +62,7 @@ public class JUnitCustomRunnerTestUnitFinderTest { @Before public void setup() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new JUnitCustomRunnerTestUnitFinder(new TestGroupConfig(), Collections.emptyList(), Collections.emptyList()); } diff --git a/pitest/src/test/java/org/pitest/junit/adapter/AdaptedJUnitTestUnitTest.java b/pitest/src/test/java/org/pitest/junit/adapter/AdaptedJUnitTestUnitTest.java index 38b4175cb..c3dd7fe16 100644 --- a/pitest/src/test/java/org/pitest/junit/adapter/AdaptedJUnitTestUnitTest.java +++ b/pitest/src/test/java/org/pitest/junit/adapter/AdaptedJUnitTestUnitTest.java @@ -37,7 +37,7 @@ public class AdaptedJUnitTestUnitTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); } private static class HideFromJUnit { diff --git a/pitest/src/test/java/org/pitest/junit/adapter/AdaptingRunListenerTest.java b/pitest/src/test/java/org/pitest/junit/adapter/AdaptingRunListenerTest.java index 77dc375d6..c4a26603f 100644 --- a/pitest/src/test/java/org/pitest/junit/adapter/AdaptingRunListenerTest.java +++ b/pitest/src/test/java/org/pitest/junit/adapter/AdaptingRunListenerTest.java @@ -44,7 +44,7 @@ public class AdaptingRunListenerTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.throwable = new NullPointerException(); this.pitDescription = DescriptionMother.createEmptyDescription("foo"); this.testee = new AdaptingRunListener(this.pitDescription, this.rc); diff --git a/pitest/src/test/java/org/pitest/junit/adapter/CustomRunnerExecutorTest.java b/pitest/src/test/java/org/pitest/junit/adapter/CustomRunnerExecutorTest.java index 411d8fd9e..14c214f41 100644 --- a/pitest/src/test/java/org/pitest/junit/adapter/CustomRunnerExecutorTest.java +++ b/pitest/src/test/java/org/pitest/junit/adapter/CustomRunnerExecutorTest.java @@ -39,7 +39,7 @@ public class CustomRunnerExecutorTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new CustomRunnerExecutor( DescriptionMother.createEmptyDescription("foo"), this.runner, this.rc); } diff --git a/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestMinionTest.java b/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestMinionTest.java index a490782a9..28b6d978e 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestMinionTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestMinionTest.java @@ -62,7 +62,7 @@ public class MutationTestMinionTest { @Before public void setup() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.mutations = new ArrayList<>(); this.tests = new ArrayList<>(); diff --git a/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestWorkerTest.java b/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestWorkerTest.java index ff6a19b53..d4c251898 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestWorkerTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTestWorkerTest.java @@ -53,7 +53,7 @@ public class MutationTestWorkerTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new MutationTestWorker(this.hotswapper, this.mutater, this.loader, false); } diff --git a/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTimeoutDecoratorTest.java b/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTimeoutDecoratorTest.java index 397ad26d1..ef3e3e5b9 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTimeoutDecoratorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/execute/MutationTimeoutDecoratorTest.java @@ -50,7 +50,7 @@ public class MutationTimeoutDecoratorTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new MutationTimeoutDecorator(this.child, this.sideEffect, this.timeoutStrategy, NORMAL_EXECUTION); } diff --git a/pitest/src/test/java/org/pitest/mutationtest/execute/TimeOutDecoratedTestSourceTest.java b/pitest/src/test/java/org/pitest/mutationtest/execute/TimeOutDecoratedTestSourceTest.java index e8ecb8fcd..d5e40a3bb 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/execute/TimeOutDecoratedTestSourceTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/execute/TimeOutDecoratedTestSourceTest.java @@ -45,7 +45,7 @@ public class TimeOutDecoratedTestSourceTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new TimeOutDecoratedTestSource(this.timeoutStrategy, Arrays.asList(makeTestUnit("one"), makeTestUnit("two")), this.reporter); diff --git a/pitest/src/test/java/org/pitest/mutationtest/execute/TimeOutSystemExitSideEffectTest.java b/pitest/src/test/java/org/pitest/mutationtest/execute/TimeOutSystemExitSideEffectTest.java index f2e89a5b4..9e14f99df 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/execute/TimeOutSystemExitSideEffectTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/execute/TimeOutSystemExitSideEffectTest.java @@ -29,7 +29,7 @@ public class TimeOutSystemExitSideEffectTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); } @Test diff --git a/pitest/src/test/java/org/pitest/mutationtest/mocksupport/BendJavassistToMyWillTransformerTest.java b/pitest/src/test/java/org/pitest/mutationtest/mocksupport/BendJavassistToMyWillTransformerTest.java index 758bacc7c..73ad62d22 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/mocksupport/BendJavassistToMyWillTransformerTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/mocksupport/BendJavassistToMyWillTransformerTest.java @@ -26,7 +26,7 @@ public class BendJavassistToMyWillTransformerTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new BendJavassistToMyWillTransformer(this.filter, JavassistInputStreamInterceptorAdapater.inputStreamAdapterSupplier(JavassistInterceptor.class)); final ClassloaderByteArraySource source = new ClassloaderByteArraySource( IsolationUtils.getContextClassLoader()); diff --git a/pitest/src/test/java/org/pitest/mutationtest/mocksupport/JavassistInputStreamInterceptorAdapaterTest.java b/pitest/src/test/java/org/pitest/mutationtest/mocksupport/JavassistInputStreamInterceptorAdapaterTest.java index ec9479195..e9633b5a9 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/mocksupport/JavassistInputStreamInterceptorAdapaterTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/mocksupport/JavassistInputStreamInterceptorAdapaterTest.java @@ -18,7 +18,7 @@ public class JavassistInputStreamInterceptorAdapaterTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new JavassistInputStreamInterceptorMethodVisitor(this.mv, "com.example.TheInterceptorClassName"); } diff --git a/pitest/src/test/java/org/pitest/testapi/execute/ExitingResultCollectorTest.java b/pitest/src/test/java/org/pitest/testapi/execute/ExitingResultCollectorTest.java index 1d88b048c..ea29b7fa4 100644 --- a/pitest/src/test/java/org/pitest/testapi/execute/ExitingResultCollectorTest.java +++ b/pitest/src/test/java/org/pitest/testapi/execute/ExitingResultCollectorTest.java @@ -37,7 +37,7 @@ public class ExitingResultCollectorTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.testee = new ExitingResultCollector(this.rc); this.description = new Description("foo", ExitingResultCollectorTest.class); } diff --git a/pitest/src/test/java/org/pitest/testapi/execute/MultipleTestGroupTest.java b/pitest/src/test/java/org/pitest/testapi/execute/MultipleTestGroupTest.java index bd639975b..0a766552b 100644 --- a/pitest/src/test/java/org/pitest/testapi/execute/MultipleTestGroupTest.java +++ b/pitest/src/test/java/org/pitest/testapi/execute/MultipleTestGroupTest.java @@ -45,7 +45,7 @@ public class MultipleTestGroupTest { @Before public void setup() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); when(this.emptyTestUnit.getDescription()).thenReturn( new Description("foo", String.class)); when(this.emptyTestUnit2.getDescription()).thenReturn( diff --git a/pitest/src/test/java/org/pitest/testapi/execute/ResultTypeTest.java b/pitest/src/test/java/org/pitest/testapi/execute/ResultTypeTest.java index 33ed1a1f3..5e98ea7f3 100644 --- a/pitest/src/test/java/org/pitest/testapi/execute/ResultTypeTest.java +++ b/pitest/src/test/java/org/pitest/testapi/execute/ResultTypeTest.java @@ -33,7 +33,7 @@ public class ResultTypeTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); } @Test diff --git a/pitest/src/test/java/org/pitest/testapi/execute/TestPitest.java b/pitest/src/test/java/org/pitest/testapi/execute/TestPitest.java index eab629c21..d2fa8caac 100644 --- a/pitest/src/test/java/org/pitest/testapi/execute/TestPitest.java +++ b/pitest/src/test/java/org/pitest/testapi/execute/TestPitest.java @@ -31,7 +31,7 @@ public class TestPitest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.container = new UnContainer(); this.testee = new Pitest(this.listener); } diff --git a/pitest/src/test/java/org/pitest/testng/TestNGAdapterTest.java b/pitest/src/test/java/org/pitest/testng/TestNGAdapterTest.java index baed6de53..155289d6f 100644 --- a/pitest/src/test/java/org/pitest/testng/TestNGAdapterTest.java +++ b/pitest/src/test/java/org/pitest/testng/TestNGAdapterTest.java @@ -45,7 +45,7 @@ public class TestNGAdapterTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.description = new Description("foo"); this.clazz = TestNGAdapterTest.class; this.testee = new TestNGAdapter(this.clazz, this.description, this.rc); diff --git a/pitest/src/test/java/org/pitest/testng/TestNGTestUnitTest.java b/pitest/src/test/java/org/pitest/testng/TestNGTestUnitTest.java index bb746e4b0..ce70cb8ea 100644 --- a/pitest/src/test/java/org/pitest/testng/TestNGTestUnitTest.java +++ b/pitest/src/test/java/org/pitest/testng/TestNGTestUnitTest.java @@ -50,7 +50,7 @@ public class TestNGTestUnitTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); this.config = new TestGroupConfig(Collections. emptyList(), Collections. emptyList()); this.includedTestMethods = Collections.emptyList(); diff --git a/pitest/src/test/java/sun/pitest/CodeCoverageStoreTest.java b/pitest/src/test/java/sun/pitest/CodeCoverageStoreTest.java index 7dd7356f0..70e8786ec 100644 --- a/pitest/src/test/java/sun/pitest/CodeCoverageStoreTest.java +++ b/pitest/src/test/java/sun/pitest/CodeCoverageStoreTest.java @@ -41,7 +41,7 @@ public class CodeCoverageStoreTest { @Before public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); CodeCoverageStore.init(this.receiver); } diff --git a/pom.xml b/pom.xml index c3eca2076..6ea6c98b8 100644 --- a/pom.xml +++ b/pom.xml @@ -144,7 +144,7 @@ org.mockito mockito-core - 3.5.13 + 3.6.28 test From 86a57e37cae00778a33a820d3407a46dc9e23438 Mon Sep 17 00:00:00 2001 From: Alexey Elin Date: Wed, 9 Dec 2020 17:04:40 +0300 Subject: [PATCH 5/5] use any(File.class) in verifications --- .../test/java/org/pitest/maven/PitMojoTest.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/pitest-maven/src/test/java/org/pitest/maven/PitMojoTest.java b/pitest-maven/src/test/java/org/pitest/maven/PitMojoTest.java index 06d5b8d46..14d9523a3 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/PitMojoTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/PitMojoTest.java @@ -2,7 +2,6 @@ import static java.util.Arrays.asList; import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; @@ -14,6 +13,8 @@ import org.apache.maven.model.Build; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.project.MavenProject; +import org.mockito.Mock; import org.pitest.coverage.CoverageSummary; import org.pitest.mutationtest.config.PluginServices; import org.pitest.mutationtest.config.ReportOptions; @@ -23,11 +24,17 @@ public class PitMojoTest extends BasePitMojoTest { + @Mock + private MavenProject executionProject; + private AbstractPitMojo testee; @Override public void setUp() throws Exception { super.setUp(); + + when(this.project.getExecutionProject()).thenReturn(executionProject); + when(this.executionProject.getBasedir()).thenReturn(new File("BASEDIR")); } public void testRunsAMutationReportWhenMutationCoverageGoalTrigered() @@ -37,7 +44,7 @@ public void testRunsAMutationReportWhenMutationCoverageGoalTrigered() build.setOutputDirectory("foo"); this.testee.getProject().setBuild(build); this.testee.execute(); - verify(this.executionStrategy).execute(isNull(), + verify(this.executionStrategy).execute(any(File.class), any(ReportOptions.class), any(PluginServices.class), anyMap()); } @@ -393,7 +400,7 @@ private void setupCoverage(long mutationScore, int lines, int linesCovered) CoverageSummary sum = new CoverageSummary(lines, linesCovered); final CombinedStatistics cs = new CombinedStatistics(stats, sum); when( - this.executionStrategy.execute(isNull(), + this.executionStrategy.execute(any(File.class), any(ReportOptions.class), any(PluginServices.class), anyMap())) .thenReturn(cs); } @@ -405,7 +412,7 @@ private void setupTestStrength(long totalMutations, long mutationDetected, long CoverageSummary sum = new CoverageSummary(0, 0); final CombinedStatistics cs = new CombinedStatistics(stats, sum); when( - this.executionStrategy.execute(isNull(), + this.executionStrategy.execute(any(File.class), any(ReportOptions.class), any(PluginServices.class), anyMap())) .thenReturn(cs); } @@ -418,7 +425,7 @@ private void setupSuvivingMutants(long survivors) CoverageSummary sum = new CoverageSummary(0, 0); final CombinedStatistics cs = new CombinedStatistics(stats, sum); when( - this.executionStrategy.execute(isNull(), + this.executionStrategy.execute(any(File.class), any(ReportOptions.class), any(PluginServices.class), anyMap())) .thenReturn(cs); }