springboot代码测试注意事项

一、springboot代码测试基本使用

在test文件夹中,需要与正式编写代码同级目录下写相应的测试文件。

@RunWith(SpringRunner.class)
@SpringBootTest
public class ProductCategoryDaoTest {
    @Autowired
    private ProductCategoryDao productCategoryDao;
    @Test
    public void findAll(){
        List<ProductCategory> abc = productCategoryDao.findAll();
        System.out.println(abc);
    }
}

二、注意事项

写测试代码,返回值必须是 void,否则系统直接报错。

 

posted @ 2020-03-08 19:37  与时飞翔  阅读(307)  评论(0编辑  收藏  举报