0
点赞
收藏
分享

微信扫一扫

Spring boot 配置单元测试


添加依赖

<!--    测试    -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

写测试类

注意测试类的目录

Spring boot 配置单元测试_java

测试类代码

【注意】
1、 类上面要写2行注解。第一行是运行环境,第二行classes = 你的启动类。
2、 测试类中方法上要加@Test
3、 测试类尽量写在src/test/java/下

@RunWith(SpringRunner.class)
@SpringBootTest(classes = MainApplication.class)
public class test01Service extends BaseServiceImpl {

@Test
public void selectMenus(){

List<SyMenu> syMenus = dao.find("from SyMenu order by menuSort asc");
for (SyMenu s : syMenus)
System.out.println(s.toString());

}
}


举报

相关推荐

0 条评论