我有以下两位选手:
@CucumberOptions(plugin = {"pretty", "json:target/cucumber_parallel_BR00.json", "junit:target/cucumber_parallel-junit-report-BR00.xml",
"rerun:target/failed_scenarios/failed_parallel_once_BR00.txt", "timeline:target/timeline_BR00"},
features = {"classpath:features/parallel/BR00"},
tags = "(@UI or @API) and (not @Ignored)",
glue = {"com.intrasoft.ermis.e2e.stepdefs"},
monochrome = true)
public class E2ECucumberParallelRunner_BR00 extends AbstractTestNGCucumberTests {和
@CucumberOptions(plugin = {"pretty", "json:target/cucumber_parallel_BR01.json", "junit:target/cucumber_parallel-junit-report-BR01.xml",
"rerun:target/failed_scenarios/failed_parallel_once_BR01.txt", "timeline:target/timeline_BR01"},
features = {"classpath:features/parallel/BR01"},
tags = "(@UI or @API) and (not @Ignored)",
glue = {"com.intrasoft.ermis.e2e.stepdefs"},
monochrome = true)
public class E2ECucumberParallelRunner_BR01 extends AbstractTestNGCucumberTests {在@BeforeAll的执行过程中,我希望检索运行程序的名称或类的名称,因为基于运行程序,我希望在所有场景之前在env中设置相同的数据
发布于 2022-07-20 14:26:11
您可以通过两个步骤来实现:
public class RunnerInfo {
private static name;
public static setName(String value){
if(name == null){
name = value;
}else{
throw new IllegalStateException("Runner name has been alread identified");
}
}
public static String getName(){
return name;
}
}public class Runner1 extends AbstractTestNGCucumberTests {
public Runner1(){
RunnerInfo.setName("My runner");
}
} 再来一次
public class Runner2 extends AbstractTestNGCucumberTests {
public Runner2(){
RunnerInfo.setName("My another runner");
}
} 现在,让我们从钩子中检索名称:
public class MyHook {
@BeforeAll
public static void globalSetUp(){
System.out.println(RunnerInfo.getName());
}
}https://stackoverflow.com/questions/73043686
复制相似问题