[关闭]
@ruoli 2017-06-21T11:46:55.000000Z 字数 701 阅读 1321

SpringBoot 进行Junit 单元测试

SpringBoot


在 src/test/java 中添加单元测试类,代码如下:

  1. package modules;
  2. import java.util.concurrent.ExecutionException;
  3. import org.junit.Test;
  4. import org.junit.runner.RunWith;
  5. import org.slf4j.Logger;
  6. import org.slf4j.LoggerFactory;
  7. import org.springframework.boot.test.context.SpringBootTest;
  8. import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  9. @RunWith(SpringJUnit4ClassRunner.class)
  10. @SpringBootTest(classes = TestApplication.class)
  11. public class AsyncTaskTests{
  12. protected final Logger logger = LoggerFactory.getLogger(this.getClass());
  13. // @Autowired
  14. // private AsyncTask asyncTask;
  15. @Test
  16. public void AsyncTaskTest() throws InterruptedException, ExecutionException {
  17. //asyncTask.doTask1();
  18. logger.info("this is logger");
  19. }
  20. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注