世界上并没有完美的程序,但是我们并不因此而沮丧,因为写程序就是一个不断追求完美的过程。
开始时测试 :
@SpringBootTest
public class TestTest {
@Autowired
TestController testController;
@Test
public void saveTest() {
testController.save(new Test("hello"));
}
}
报错,后来:
@SpringBootTest
public class TestTest {
@Autowired
@Mock
TestDao testDao;
@Autowired
@Mock
TestService testService;
@Autowired
@InjectMocks
TestController testController;
@Test
public void saveTest() {
testController.save(new Test("hello"));
}
}