From 08e93e8da504fe7533ebab70b6a5047095c72cfd Mon Sep 17 00:00:00 2001 From: dupirefr Date: Sun, 8 Mar 2020 09:06:30 +0100 Subject: [PATCH] [JAVA-134] Created a powermockito module that uses version 2.21.0 version of Mockito --- testing-modules/mockito/pom.xml | 13 -------- testing-modules/pom.xml | 1 + testing-modules/powermockito/pom.xml | 33 +++++++++++++++++++ .../CollaboratorForPartialMocking.java | 0 .../CollaboratorWithFinalMethods.java | 0 .../CollaboratorWithStaticMethods.java | 0 .../introduction/LuckyNumberGenerator.java | 0 .../LuckyNumberGeneratorUnitTest.java | 0 .../introduction/PowerMockitoUnitTest.java | 2 +- 9 files changed, 35 insertions(+), 14 deletions(-) create mode 100644 testing-modules/powermockito/pom.xml rename testing-modules/{mockito => powermockito}/src/test/java/com/baeldung/powermockito/introduction/CollaboratorForPartialMocking.java (100%) rename testing-modules/{mockito => powermockito}/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithFinalMethods.java (100%) rename testing-modules/{mockito => powermockito}/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithStaticMethods.java (100%) rename testing-modules/{mockito => powermockito}/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGenerator.java (100%) rename testing-modules/{mockito => powermockito}/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorUnitTest.java (100%) rename testing-modules/{mockito => powermockito}/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java (98%) diff --git a/testing-modules/mockito/pom.xml b/testing-modules/mockito/pom.xml index aae3981c66..ea5ef4c322 100644 --- a/testing-modules/mockito/pom.xml +++ b/testing-modules/mockito/pom.xml @@ -44,19 +44,6 @@ - - - org.powermock - powermock-module-junit4 - ${powermock.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.version} - test - org.springframework.boot spring-boot-starter diff --git a/testing-modules/pom.xml b/testing-modules/pom.xml index f4a8368581..e413e02e48 100644 --- a/testing-modules/pom.xml +++ b/testing-modules/pom.xml @@ -40,6 +40,7 @@ xmlunit-2 junit-4 testing-libraries + powermockito diff --git a/testing-modules/powermockito/pom.xml b/testing-modules/powermockito/pom.xml new file mode 100644 index 0000000000..fde7bfe78c --- /dev/null +++ b/testing-modules/powermockito/pom.xml @@ -0,0 +1,33 @@ + + + + testing-modules + com.baeldung + 1.0.0-SNAPSHOT + + 4.0.0 + + powermockito + + + + org.powermock + powermock-module-junit4 + ${powermock.version} + test + + + org.powermock + powermock-api-mockito2 + ${powermock.version} + test + + + + + 2.21.0 + 2.0.2 + + \ No newline at end of file diff --git a/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorForPartialMocking.java b/testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorForPartialMocking.java similarity index 100% rename from testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorForPartialMocking.java rename to testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorForPartialMocking.java diff --git a/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithFinalMethods.java b/testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithFinalMethods.java similarity index 100% rename from testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithFinalMethods.java rename to testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithFinalMethods.java diff --git a/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithStaticMethods.java b/testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithStaticMethods.java similarity index 100% rename from testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithStaticMethods.java rename to testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithStaticMethods.java diff --git a/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGenerator.java b/testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGenerator.java similarity index 100% rename from testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGenerator.java rename to testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGenerator.java diff --git a/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorUnitTest.java b/testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorUnitTest.java similarity index 100% rename from testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorUnitTest.java rename to testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorUnitTest.java diff --git a/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java b/testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java similarity index 98% rename from testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java rename to testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java index 4943b0486a..1b2bb99896 100644 --- a/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java +++ b/testing-modules/powermockito/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java @@ -68,7 +68,7 @@ public class PowerMockitoUnitTest { when(mock.finalMethod()).thenReturn("I am a final mock method."); returnValue = mock.finalMethod(); - verify(mock,times(3)).finalMethod(); + verify(mock).finalMethod(); assertEquals("I am a final mock method.", returnValue); when(mock, "privateMethod").thenReturn("I am a private mock method.");