From 824acb9351121e6dc912402a943e87e7369f4bec Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Thu, 26 Sep 2019 11:08:01 +0530 Subject: [PATCH] BAEL-17703 Fix the integrations tests in mockito (#7871) * BAEL-17703 Fix the integrations tests in mockito - Upgraded power-mockito api 2 jar - Renamed many IntegrationTests back to UnitTests as they do not require any integration components * BAEL-17703 Fix the integrations tests in mockito -Renamed MockFinals to MockFinalsUnitTest so that it can be picked by builds --- testing-modules/mockito/pom.xml | 2 +- ...egrationTest.java => LuckyNumberGeneratorUnitTest.java} | 2 +- ...ckitoIntegrationTest.java => PowerMockitoUnitTest.java} | 7 +++---- ...MockitoIntegrationTest.java => BDDMockitoUnitTest.java} | 2 +- .../mockito/{MockFinals.java => MockFinalsUnitTest.java} | 2 +- ...IntegrationTest.java => MockitoAnnotationUnitTest.java} | 2 +- ...grationTest.java => MockitoConfigExamplesUnitTest.java} | 2 +- ...nIntegrationTest.java => MockitoExceptionUnitTest.java} | 2 +- ...toMockIntegrationTest.java => MockitoMockUnitTest.java} | 2 +- ...grationTest.java => MockitoVerifyExamplesUnitTest.java} | 2 +- ...kitoSpyIntegrationTest.java => MockitoSpyUnitTest.java} | 2 +- 11 files changed, 13 insertions(+), 14 deletions(-) rename testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/{LuckyNumberGeneratorIntegrationTest.java => LuckyNumberGeneratorUnitTest.java} (97%) rename testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/{PowerMockitoIntegrationTest.java => PowerMockitoUnitTest.java} (94%) rename testing-modules/mockito/src/test/java/org/baeldung/bddmockito/{BDDMockitoIntegrationTest.java => BDDMockitoUnitTest.java} (98%) rename testing-modules/mockito/src/test/java/org/baeldung/mockito/{MockFinals.java => MockFinalsUnitTest.java} (95%) rename testing-modules/mockito/src/test/java/org/baeldung/mockito/{MockitoAnnotationIntegrationTest.java => MockitoAnnotationUnitTest.java} (98%) rename testing-modules/mockito/src/test/java/org/baeldung/mockito/{MockitoConfigExamplesIntegrationTest.java => MockitoConfigExamplesUnitTest.java} (98%) rename testing-modules/mockito/src/test/java/org/baeldung/mockito/{MockitoExceptionIntegrationTest.java => MockitoExceptionUnitTest.java} (97%) rename testing-modules/mockito/src/test/java/org/baeldung/mockito/{MockitoMockIntegrationTest.java => MockitoMockUnitTest.java} (98%) rename testing-modules/mockito/src/test/java/org/baeldung/mockito/{MockitoVerifyExamplesIntegrationTest.java => MockitoVerifyExamplesUnitTest.java} (98%) rename testing-modules/mockito/src/test/java/org/baeldung/mockito/spy/{MockitoSpyIntegrationTest.java => MockitoSpyUnitTest.java} (97%) diff --git a/testing-modules/mockito/pom.xml b/testing-modules/mockito/pom.xml index 7b6d6e7735..f307b80370 100644 --- a/testing-modules/mockito/pom.xml +++ b/testing-modules/mockito/pom.xml @@ -96,7 +96,7 @@ 19.0 - 1.7.0 + 2.0.2 2.0.0.0 2.1.1 diff --git a/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorIntegrationTest.java b/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorUnitTest.java similarity index 97% rename from testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorIntegrationTest.java rename to testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorUnitTest.java index 5e311c60f2..5b66aa0a9e 100644 --- a/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorIntegrationTest.java +++ b/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorUnitTest.java @@ -14,7 +14,7 @@ import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) @PrepareForTest(fullyQualifiedNames = "com.baeldung.powermockito.introduction.LuckyNumberGenerator") -public class LuckyNumberGeneratorIntegrationTest { +public class LuckyNumberGeneratorUnitTest { @Test public final void givenPrivateMethodWithReturn_whenUsingPowerMockito_thenCorrect() throws Exception { diff --git a/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoIntegrationTest.java b/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java similarity index 94% rename from testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoIntegrationTest.java rename to testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java index 1b6431f0c2..4943b0486a 100644 --- a/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoIntegrationTest.java +++ b/testing-modules/mockito/src/test/java/com/baeldung/powermockito/introduction/PowerMockitoUnitTest.java @@ -13,7 +13,7 @@ import static org.powermock.api.mockito.PowerMockito.*; @RunWith(PowerMockRunner.class) @PrepareForTest(fullyQualifiedNames = "com.baeldung.powermockito.introduction.*") -public class PowerMockitoIntegrationTest { +public class PowerMockitoUnitTest { @Test public void givenFinalMethods_whenUsingPowerMockito_thenCorrect() throws Exception { @@ -44,10 +44,10 @@ public class PowerMockitoIntegrationTest { assertEquals("Hello Baeldung!", firstWelcome); assertEquals("Hello Baeldung!", secondWelcome); - verifyStatic(times(2)); + verifyStatic(CollaboratorWithStaticMethods.class, times(2)); CollaboratorWithStaticMethods.firstMethod(Mockito.anyString()); - verifyStatic(Mockito.never()); + verifyStatic(CollaboratorWithStaticMethods.class, Mockito.never()); CollaboratorWithStaticMethods.secondMethod(); CollaboratorWithStaticMethods.thirdMethod(); @@ -60,7 +60,6 @@ public class PowerMockitoIntegrationTest { spy(CollaboratorForPartialMocking.class); when(CollaboratorForPartialMocking.staticMethod()).thenReturn("I am a static mock method."); returnValue = CollaboratorForPartialMocking.staticMethod(); - verifyStatic(); CollaboratorForPartialMocking.staticMethod(); assertEquals("I am a static mock method.", returnValue); diff --git a/testing-modules/mockito/src/test/java/org/baeldung/bddmockito/BDDMockitoIntegrationTest.java b/testing-modules/mockito/src/test/java/org/baeldung/bddmockito/BDDMockitoUnitTest.java similarity index 98% rename from testing-modules/mockito/src/test/java/org/baeldung/bddmockito/BDDMockitoIntegrationTest.java rename to testing-modules/mockito/src/test/java/org/baeldung/bddmockito/BDDMockitoUnitTest.java index e0ca6f0a35..977a60933f 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/bddmockito/BDDMockitoIntegrationTest.java +++ b/testing-modules/mockito/src/test/java/org/baeldung/bddmockito/BDDMockitoUnitTest.java @@ -10,7 +10,7 @@ import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; -public class BDDMockitoIntegrationTest { +public class BDDMockitoUnitTest { PhoneBookService phoneBookService; PhoneBookRepository phoneBookRepository; diff --git a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockFinals.java b/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockFinalsUnitTest.java similarity index 95% rename from testing-modules/mockito/src/test/java/org/baeldung/mockito/MockFinals.java rename to testing-modules/mockito/src/test/java/org/baeldung/mockito/MockFinalsUnitTest.java index caa456c891..000774592c 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockFinals.java +++ b/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockFinalsUnitTest.java @@ -8,7 +8,7 @@ import static org.mockito.Mockito.when; import org.baeldung.mockito.voidmethods.MyList; -public class MockFinals { +public class MockFinalsUnitTest { @Test public void whenMockFinalClassMockWorks() { diff --git a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoAnnotationIntegrationTest.java b/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoAnnotationUnitTest.java similarity index 98% rename from testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoAnnotationIntegrationTest.java rename to testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoAnnotationUnitTest.java index 5e083adbf5..6bc0e69e65 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoAnnotationIntegrationTest.java +++ b/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoAnnotationUnitTest.java @@ -11,7 +11,7 @@ import java.util.Map; import static org.junit.Assert.assertEquals; //@RunWith(MockitoJUnitRunner.class) -public class MockitoAnnotationIntegrationTest { +public class MockitoAnnotationUnitTest { @Mock private List mockedList; diff --git a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoConfigExamplesIntegrationTest.java b/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoConfigExamplesUnitTest.java similarity index 98% rename from testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoConfigExamplesIntegrationTest.java rename to testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoConfigExamplesUnitTest.java index 096bbe1ed7..c065e164c5 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoConfigExamplesIntegrationTest.java +++ b/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoConfigExamplesUnitTest.java @@ -13,7 +13,7 @@ import static org.mockito.Mockito.*; import org.baeldung.mockito.voidmethods.MyList; -public class MockitoConfigExamplesIntegrationTest { +public class MockitoConfigExamplesUnitTest { // tests diff --git a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoExceptionIntegrationTest.java b/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoExceptionUnitTest.java similarity index 97% rename from testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoExceptionIntegrationTest.java rename to testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoExceptionUnitTest.java index 9a25ccb28c..88da16ae2b 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoExceptionIntegrationTest.java +++ b/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoExceptionUnitTest.java @@ -8,7 +8,7 @@ import static org.mockito.Mockito.when; import org.junit.Test; import org.mockito.Mockito; -public class MockitoExceptionIntegrationTest { +public class MockitoExceptionUnitTest { @Test(expected = NullPointerException.class) public void whenConfigNonVoidRetunMethodToThrowEx_thenExIsThrown() { diff --git a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoMockIntegrationTest.java b/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoMockUnitTest.java similarity index 98% rename from testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoMockIntegrationTest.java rename to testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoMockUnitTest.java index de26642ede..30c843ff13 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoMockIntegrationTest.java +++ b/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoMockUnitTest.java @@ -17,7 +17,7 @@ import org.mockito.exceptions.verification.TooLittleActualInvocations; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -public class MockitoMockIntegrationTest { +public class MockitoMockUnitTest { private static class CustomAnswer implements Answer { @Override diff --git a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesIntegrationTest.java b/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesUnitTest.java similarity index 98% rename from testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesIntegrationTest.java rename to testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesUnitTest.java index 9c71b1fc4f..a6e40b84e1 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesIntegrationTest.java +++ b/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesUnitTest.java @@ -16,7 +16,7 @@ import static org.junit.Assert.assertThat; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.*; -public class MockitoVerifyExamplesIntegrationTest { +public class MockitoVerifyExamplesUnitTest { // tests diff --git a/testing-modules/mockito/src/test/java/org/baeldung/mockito/spy/MockitoSpyIntegrationTest.java b/testing-modules/mockito/src/test/java/org/baeldung/mockito/spy/MockitoSpyUnitTest.java similarity index 97% rename from testing-modules/mockito/src/test/java/org/baeldung/mockito/spy/MockitoSpyIntegrationTest.java rename to testing-modules/mockito/src/test/java/org/baeldung/mockito/spy/MockitoSpyUnitTest.java index d0b838a789..068a4c6de9 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/mockito/spy/MockitoSpyIntegrationTest.java +++ b/testing-modules/mockito/src/test/java/org/baeldung/mockito/spy/MockitoSpyUnitTest.java @@ -12,7 +12,7 @@ import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) -public class MockitoSpyIntegrationTest { +public class MockitoSpyUnitTest { @Spy private List aSpyList = new ArrayList();