Springboot项目使用TestNG框架进行单元测试
文章目录
1、前言
TestNG包含了Junit4的核心功能,并且可以配合其他软件进行集成测试,功能十分强大,所以选择TestNG进行单元测试。
TestNG和Junit的区别可参考该文章https://blog.csdn.net/weixin_30808253/article/details/96516421
2、添加依赖
在SpringBoot项目的pom文件中添加依赖:
<!-- testng -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.1.1.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.1.RELEASE</version