标签:xxx dem 工程 mamicode group 注意 新建 http 准备
准备工作:
1.pom.xml文件中新增所需的依赖:
<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <!-- <scope>test</scope> --> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
2.在src/test/java中新建一个和src/main/java的xxxApplication.java文件所在的目录一样的目录(如果你是新建的springboot工程,下图中标红的目录是自动创建的)。
3.以2为例,我们所有的测试代码均要在src/test/java下的com.example.demo下编写,否则报错出现initializationerror初始化异常。
使用springboot 单元测试注意事项(不注意的话,在单元测试时会报错:出现initializationerror初始化异常)
标签:xxx dem 工程 mamicode group 注意 新建 http 准备
原文地址:https://www.cnblogs.com/dyys/p/10483963.html