我正在尝试使用含有selenium + java的黄瓜,并通过cli api调用黄瓜:
public static void main(String[] args){
Main.main(new String[] {"-p","pretty",... }
//code needs to be executed after cucumber main is here
}
我想在黄瓜主执行完成后执行代码的某些部分。但是一旦黄瓜完成执行,程序就会终止。如何执行黄瓜cli main之后编写的代码片段。
答案 0 :(得分:0)
如果你想这样做,你可能需要重写cumcumber cli api main方法。以下示例代码可以帮助您:
import cucumber.api.cli.Main;
public class Execute extends Main{
public static void main(String[] argv) throws Throwable {
String[] options = {"-g", "StepDfination","--plugin","/path/to/json/report.json", "-t", "<your tag what you need to test", "/path/to/your/feature.feature"};
byte exitstatus = run(options, Thread.currentThread().getContextClassLoader());
//Do somethings after all cucumber test finished.
DriverUtil.closeDriver();
ReportUtil.ouputHtmlReport("/path/to/json/report.json");
System.exit(exitstatus);
}
}