java - 使用 java/IntelliJ 运行 Cucumber 时出错

标签 java intellij-idea cucumber

我已经在 intelliJ 中使用 Java 设置了 Cucumber,并且刚刚将我的功能文件粘贴到我的步骤文件并尝试运行它。它并没有真正测试任何东西——它应该会通过。但我收到此警告/错误。我正在通过教程学习,并且完全按照步骤进行操作,所以无法理解为什么会发生这种情况?有人可以帮忙吗?错误如下:

    WARNING: An illegal reflective access operation has occurred
    WARNING: Illegal reflective access by cucumber.deps.com.thoughtworks.xstream.core.util.Fields (file:/C:/Users/Kristian.Senior/.m2/repository/io/cucumber/cucumber-jvm-deps/1.0.6/cucumber-jvm-deps-1.0.6.jar) to field java.util.TreeMap.comparator
    WARNING: Please consider reporting this to the maintainers of cucumber.deps.com.thoughtworks.xstream.core.util.Fields
    WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
    WARNING: All illegal access operations will be denied in a future release

    Skipped step

    Skipped step

    Skipped step

    Skipped step

    1 Scenarios (1 pending)
    4 Steps (3 skipped, 1 pending)
    0m0.393s

    cucumber.api.PendingException: TODO: implement me
        at Steps.LoginFeature.iNavigateToTheLoginPage(LoginFeature.java:18)
        at ✽.I navigate to the login page(C:/Users/Kristian.Senior/CucumberBasics/src/test/java/Features/login.feature:6)

最佳答案

你得到了异常(exception)

cucumber.api.PendingException: TODO: implement me
        at Steps.LoginFeature.iNavigateToTheLoginPage(LoginFeature.java:18)
        at ✽.I navigate to the login page(C:/Users/Kristian.Senior/CucumberBasics/src/test/java/Features/login.feature:6)

这会强制您执行异常中描述的步骤。

实现步骤如下:

@When("I navigate to the login")
public void i_navigate_to_the_login() {
    System.out.printf("Navigating to login\n");
}

为了跳过这些步骤,您可以在 CucumberOptions 中设置 strict 选项

Strict: if the strict option is set to false then at execution time if cucumber encounters any undefined/pending steps then cucumber does not fail the execution and undefined steps are skipped and BUILD is SUCCESSFUL.

关于java - 使用 java/IntelliJ 运行 Cucumber 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55238108/

相关文章:

java - 我不明白 web.xml 在使用 servlet 时如何工作/应该工作

java - 用 Java 绘制 pacman

java - 获取 HashMap

java - 尝试获取 InputStream 时出现错误 502/504

gradle - 在Intellij中遇到Gradle构建失败;要求更新5.0+

intellij-idea - 修改IntelliJ Javadoc模板

protractor - 有没有办法将公共(public)特征文件导入 cucumber 中的另一个特征文件

Scala 代码在 Intellij 上运行,但不在 Apache Zeppelin notebook 上运行

selenium - 而不是 sendkeys 最后从剪贴板复制的项目被输入到元素中

ruby - 在 TeamCity 上构建和测试命令行 Gem