@RunWith(MockitoJUnitRunner.class) @TestPropertySource("classpath:application-test.properties") public class DemoTest{ @InjectMocks private Service service; @Mock private Dao dao; @Test public void test() { when(dao.xxx(any(), any())).thenReturn(new xxx()); service.xxx(); asertXXX.. }
相互学习,共同进步!