我编写了一个 CucumberJVM 测试工具和大量功能文件来测试我的应用程序。其中一些测试可能需要 10 到 20 分钟才能运行,这意味着测试工具似乎会长时间挂起。
为了让我的最终用户相信机器没有锁定,我想在每个场景开始时做的是打印场景名称。我知道 @Before 可用于定义在每次测试开始之前执行的粘合方法。所以我的问题是:
“如何在 @Before 带注释的方法中获取场景名称”
最佳答案
我假设您正在使用 junit 运行程序,所以这是一个简单的示例。
@RunWith(Cucumber.class)
@CucumberOptions(
features = "classpath:features/something.feature",
format = "com.blah.PrintingFormatter",
glue = "com.blah.steps")
public class CucumberTest {
}
然后你的 PrintingFormatter 应该实现 gherkin.formatter.Formatter 接口(interface),特别是 startOfScenarioLifeCycle 方法。将 println 放在那里就可以了。
关于java - cucumber JVM : Need to write Scenario name at start of each test,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21135225/