on 08-25-2015 5:29 PM
Need to write a junit unit test for custom populator
Something as simple as this....
@UnitTest
@RunWith(MockitoJUnitRunner.class)
public class MyDataPopuatorTest {
private Popuator<SomeModel, SomeData> populator;
private static final String FILENAME = "File 1";
@Mock
private SomeModel source;
@Mock
private SomeData target;
@Before
public void setUp() {
populator = new MyDataPopuator();
when(source.getFilename()).thenReturn(FILENAME);
}
@Test
public void filenameIsSetOnDataTarget() {
populator.populate(source, target);
verify(target).setFilename(FILENAME);
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
unit test case using mockito
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.