一、测试一般程序
1.1 测试步骤
- 在
pom.xml
中加入测试环境的依赖。 - 在测试类上加入
@RunWith(SpringRunner.class)
与@SpringBootTest
注解。
1.2 简单测试例子
在pom.xml
中引入相关依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
要测试的程序代码
@Repository
public class UserDao {
public void addUser(String username){
if(username.equals("zhangsan")){
System.out.println("===============");
}else {
System.out.println(