JAVA-12032 Move Mockito ebook articles code to common module - mockito-simple- Delete mockito-3 since it had only 1 article which was moved to mockito-simple
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package com.baeldung.mockito;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.baeldung.mockito.MyList;
|
||||
|
||||
public class MockFinalsUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenMockFinalClassMockWorks() {
|
||||
|
||||
FinalList finalList = new FinalList();
|
||||
|
||||
FinalList mock = mock(FinalList.class);
|
||||
when(mock.size()).thenReturn(2);
|
||||
|
||||
assertNotEquals(mock.size(), finalList.size());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenMockFinalMethodMockWorks() {
|
||||
|
||||
MyList myList = new MyList();
|
||||
|
||||
MyList mock = mock(MyList.class);
|
||||
when(mock.finalMethod()).thenReturn(1);
|
||||
|
||||
assertNotEquals(mock.finalMethod(), myList.finalMethod());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user