java - cucumber JVM : Need to write Scenario name at start of each test

标签 java cucumber-jvm

我编写了一个 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/

相关文章:

java - 结果集在 .next() 第一次迭代时关闭异常

cucumber - 使用 cucumber-jvm 4 并行运行 cucumber 测试

java - 我在这段代码上得到了 StackOverFlowException,因为我的 JVM 不支持尾调用优化,对吧?

java - JBoss 4.2.3 - 如何查找 jar 文件的路径

java - 无法在 Mac 上安装 Eclipse - "Failed to create the Java Virtual Machine"

java - Cucumber - 无法使用运行器运行测试

java - 'java.lang.String' io.cucumber.java @After 注释的初始化程序非法

java - 在 cucumber / Selenium 中,当我想将多个参数作为字符串传递时,我遇到了问题

java - 无法正确设置类路径

java - 通过每次出现时最后一个分隔符的存在将字符串拆分为数组的惯用方法