Created
February 6, 2018 16:46
-
-
Save iamsurya-dev/a30993f0ab6fe83455776125f44c0f1c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.Assert; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.powermock.api.mockito.PowerMockito; | |
import org.powermock.core.classloader.annotations.PrepareForTest; | |
import org.powermock.modules.junit4.PowerMockRunner; | |
@RunWith(PowerMockRunner.class) | |
@PrepareForTest(PeopleUtil.class) | |
public class PeopleTest() { | |
private People people; | |
@Test | |
public void getNameTest() { | |
// Mock PeopleUtil class over here | |
PowerMockito.mockStatic(PeopleUtil.class); | |
PowerMockito.when(PeopleUtil.getPerson()).thenReturn("TestName"); | |
people = new People(); | |
Assert.assertEquals("TestName", people.getName()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment