需要通过Gradle和Spring配置文件来运行测试。
gradle clean build
我已添加任务:
task beforeTest() {
doLast {
System.setProperty("spring.profiles.active", "DEV")
}
}
test.dependsOn beforeTest
我的测试定义如下:
@RunWith(SpringRunner.class)
@SpringBootTest
@ActiveProfiles("TestProfile")
public class SomeTest {
但是这个结构对我没用。
Gradle 运行测试。