Created
January 12, 2019 04:01
-
-
Save jieniu/1136aacd63035876da8fc7aaf9d2afba to your computer and use it in GitHub Desktop.
inject mock object when ut
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
@RunWith(PowerMockRunner.class) | |
@PrepareForTest({DatasetInfoDao.class, DatasetResource.class}) | |
public class DatasetResourceTest { | |
@Test | |
public void testIsDumpTimingValidTrue() throws Exception { | |
DatasetInfoDao dao = PowerMockito.mock(DatasetInfoDao.class); | |
PowerMockito.when(dao, "getCreatetimeByGroupIdAndDocName", Mockito.any(String.class), Mockito.any(String.class)).thenReturn(null); | |
DatasetResource resource = PowerMockito.spy(new DatasetResource()); | |
MemberModifier.field(DatasetResource.class, "datasetInfoDao").set(resource, dao); | |
boolean ret = resource.dumpTimingValidation("1001", "tablename"); | |
Assert.assertTrue(ret==true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment