使用junit4 测试
pom.xml 依赖
1
2
3
4
5
6
7
8
9
10
11
12
13
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
1
2
3
4
5
6
7
8
9
10
11
@RunWith(SpringRunner.class) // 引入spring运行环境的context
@SpringBootTest
public class StorageBuildTest {
// 设置配置文件属性
@BeforeClass
public static void setSystemProperty() {
Properties properties = System.getProperties();
properties.setProperty("property.type", "4");
}
}