上@ perseger的回答擴展,下面專門亞軍允許您使用@ActiveProfiles註釋
public class SpringProfileCucumber extends Cucumber {
public SpringProfileCucumber(Class clazz)
throws InitializationError, IOException {
super(clazz);
ActiveProfiles ap = (ActiveProfiles) clazz
.getAnnotation(ActiveProfiles.class);
if (ap != null) {
System.setProperty("spring.profiles.active",
String.join(",", ap.value()));
}
}
}
在測試中,你就可以使用
@RunWith(SpringProfileCucumber.class)
@CucumberOptions(...)
@ActiveProfiles("testProfile")
public class RyvrTests {
}
工作就像對我的魅力。謝謝! –