我有一个应用程序,我正在使用不同的技术进行试用。我有一套使用每种技术实现的接口,我使用弹簧配置文件来决定运行哪种技术。每种技术都有自己的Spring java配置,并注明了它们的活动配置文件。是否可以配置黄瓜运行不同的春季配置文件相同的测试?
我跑我的黄瓜测试确定哪种模式处于活动状态,但是这迫使我我想测试一个不同的配置文件每次手动更改字符串,使其无法运行所有这些自动化测试。无论如何,在黄瓜提供一套配置文件,所以测试每个运行一次?
谢谢!
我有一个应用程序,我正在使用不同的技术进行试用。我有一套使用每种技术实现的接口,我使用弹簧配置文件来决定运行哪种技术。每种技术都有自己的Spring java配置,并注明了它们的活动配置文件。是否可以配置黄瓜运行不同的春季配置文件相同的测试?
我跑我的黄瓜测试确定哪种模式处于活动状态,但是这迫使我我想测试一个不同的配置文件每次手动更改字符串,使其无法运行所有这些自动化测试。无论如何,在黄瓜提供一套配置文件,所以测试每个运行一次?
谢谢!
你有两种可能性
在第一种情况下,它将如下所示。缺点是你必须为每个运动员定义不同的报告,并为每个配置使用几乎相同的Cucumber运动员。
这里的类怎么能是这样的:
CucumberRunner1.java
@RunWith(Cucumber.class)
@CucumberOptions(glue = {"com.abc.def", "com.abc.common"},
features = {"classpath:com/abc/def/",
"classpath:com/abc/common.feature"},
format = {"json:target/cucumber/cucumber-report-1.json"},
tags = {"[email protected]"},
monochrome = true)
public class CucumberRunner1 {
}
StepAndConfig1.java
@ContextConfiguration(locations = {"classpath:/com/abc/def/configuration1.xml"})
public class StepsAndConfig1 {
@Then("^some useful step$")
public void someStep(){
int a = 0;
}
}
CucumberRunner2.java
@RunWith(Cucumber.class)
@CucumberOptions(glue = {"com.abc.ghi", "com.abc.common"},
features = {"classpath:com/abc/ghi/",
"classpath:com/abc/common.feature"},
format = {"json:target/cucumber/cucumber-report-2.json"},
tags = {"[email protected]"},
monochrome = true)
public class CucumberRunner2 {
}
OnlyConfig2.java
@ContextConfiguration(classes = JavaConfig2.class)
public class OnlyConfig2 {
@Before
public void justForCucumberToPickupThisClass(){}
}
第二种方法是到使用支持多个配置定制黄瓜转轮。你可以自己写或准备一个,例如,我的 - CucumberJar.java和项目cucumber-junit的根。 在这种情况下黄瓜亚军将是这样的:
CucumberJarRunner.java
@RunWith(CucumberJar.class)
@CucumberOptions(glue = {"com.abc.common"},
tags = {"[email protected]"},
plugin = {"json:target/cucumber/cucumber-report-common.json"})
@CucumberGroupsOptions({
@CucumberOptions(glue = {"com.abc.def"},
features = {"classpath:com/abc/def/",
"classpath:com/abc/common.feature"}
),
@CucumberOptions(glue = {"com.abc.ghi"},
features = {"classpath:com/abc/ghi/",
"classpath:com/abc/common.feature"}
)
})
public class CucumberJarRunner {
}
哇,感谢您的!这是有点晚了,我到现在实现这个视后正好一岁,但下一次我必须做同样的事情,我会记住这一点:d – Kilian
毫米,由于某种原因,我认为这是今年以来的问题:) – nahab