如何在 Cucumber CLI 中使用钩子?
How to use hooks with cucumber CLI?
我正在使用 Cucumber CLI,需要使用钩子 @Before、@After、@BeforeClass、@AfterClass。我在项目的 class 中声明了钩子,但是当我使用 CLI 运行
时,黄瓜忽略了它们
public class Runner {
public static void main(String[] args) throws Exception {
args2 = new String[] { path + "/features", "--glue", "stepFiles",
"--threads", threadsQty, "", "--tags", tags};
cucumber.api.cli.Main.run(args2,Thread.currentThread().getContextClassLoader());
}
@Before
public void beforeScenario() {
System.out.println("This will run before the Scenario");
}
@After
public void afterScenario() {
System.out.println("This will run after the Scenario");
}
}
挂钩class必须作为胶水添加。尝试
args2 = new String[] { path + "/features", "--glue", "stepFiles", "--glue","<your hook class>", "--threads", threadsQty, "", "--tags", tags};
我正在使用 Cucumber CLI,需要使用钩子 @Before、@After、@BeforeClass、@AfterClass。我在项目的 class 中声明了钩子,但是当我使用 CLI 运行
时,黄瓜忽略了它们public class Runner {
public static void main(String[] args) throws Exception {
args2 = new String[] { path + "/features", "--glue", "stepFiles",
"--threads", threadsQty, "", "--tags", tags};
cucumber.api.cli.Main.run(args2,Thread.currentThread().getContextClassLoader());
}
@Before
public void beforeScenario() {
System.out.println("This will run before the Scenario");
}
@After
public void afterScenario() {
System.out.println("This will run after the Scenario");
}
}
挂钩class必须作为胶水添加。尝试
args2 = new String[] { path + "/features", "--glue", "stepFiles", "--glue","<your hook class>", "--threads", threadsQty, "", "--tags", tags};