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
This commit is contained in:
parent
f4ddb32ae4
commit
824acb9351
|
@ -96,7 +96,7 @@
|
|||
<guava.version>19.0</guava.version>
|
||||
|
||||
<!-- testing -->
|
||||
<powermock.version>1.7.0</powermock.version>
|
||||
<powermock.version>2.0.2</powermock.version>
|
||||
<hamcrest.version>2.0.0.0</hamcrest.version>
|
||||
<javax.persistence.version>2.1.1</javax.persistence.version>
|
||||
</properties>
|
||||
|
|
|
@ -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 {
|
|
@ -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);
|
||||
|
|
@ -10,7 +10,7 @@ import org.mockito.Mockito;
|
|||
import org.mockito.invocation.InvocationOnMock;
|
||||
|
||||
|
||||
public class BDDMockitoIntegrationTest {
|
||||
public class BDDMockitoUnitTest {
|
||||
|
||||
PhoneBookService phoneBookService;
|
||||
PhoneBookRepository phoneBookRepository;
|
|
@ -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() {
|
|
@ -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<String> mockedList;
|
|
@ -13,7 +13,7 @@ import static org.mockito.Mockito.*;
|
|||
|
||||
import org.baeldung.mockito.voidmethods.MyList;
|
||||
|
||||
public class MockitoConfigExamplesIntegrationTest {
|
||||
public class MockitoConfigExamplesUnitTest {
|
||||
|
||||
// tests
|
||||
|
|
@ -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() {
|
|
@ -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<Boolean> {
|
||||
@Override
|
|
@ -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
|
||||
|
|
@ -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<String> aSpyList = new ArrayList<String>();
|
Loading…
Reference in New Issue