cancel
Showing results for 
Search instead for 
Did you mean: 

how to create a junit test for custom populator

Former Member

Need to write a junit unit test for custom populator

Former Member
0 Kudos

Integration type test using the junit tennat or a common Java JUnit test?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

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);
     }
 }

Former Member
0 Kudos

unit test case using mockito