File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
etleap/src/test/java/us/hxbc/etleap Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -34,5 +34,20 @@ public void testStart() throws Exception {
3434 service .start (1000 );
3535 Thread .sleep (1500 );
3636 service .stop ();
37+ //verify(service, atLeastOnce()).update();
38+ /*
39+ the above test fails with:
40+ org.mockito.exceptions.verification.WantedButNotInvoked:
41+ Wanted but not invoked:
42+ updateService.update();
43+ -> at us.hxbc.etleap.UpdateServiceTest.testStart(UpdateServiceTest.java:37)
44+
45+ However, there were other interactions with this mock:
46+ updateService.start(1000);
47+ -> at us.hxbc.etleap.UpdateServiceTest.testStart(UpdateServiceTest.java:34)
48+
49+ updateService.stop();
50+ -> at us.hxbc.etleap.UpdateServiceTest.testStart(UpdateServiceTest.java:36)
51+ */
3752 }
3853}
Original file line number Diff line number Diff line change @@ -41,12 +41,9 @@ public void testGetUpdatePath() throws Exception {
4141
4242 @ Test
4343 public void testApply () throws Exception {
44- FileConfig configMock = mock (FileConfig .class );
45- when (configMock .getPath ()).thenReturn (config .getPath ());
46- when (configMock .getUpdatePath ()).thenReturn (config .getUpdatePath ());
47- when (configMock .openStream ()).thenReturn (new ByteArrayInputStream ("hello world" .getBytes ()));
44+ FileConfig configMock = spy (config );
45+ doReturn (new ByteArrayInputStream ("hello world" .getBytes ())).when (configMock ).openStream ();
4846 configMock .apply ();
49- verify (configMock , atLeastOnce ()).apply ();
5047 assertThat (configMock .getPath ()).hasContent ("hello world" );
5148 }
5249}
You can’t perform that action at this time.
0 commit comments