【问题标题】:Cucumber-jvm feature file and step definition file implementation issueCucumber-jvm 功能文件和步骤定义文件实现问题
【发布时间】:2018-10-27 05:26:03
【问题描述】:

我是 Cucumber 框架的新手,并使用 Cucumber 框架设计了一个 selenium maven 项目。 但是我上周一直在努力解决一个问题,我已经在互联网上探索了所有可能的解决方案。例如。将运行器和步骤定义文件放在 src/test 目录下,将功能文件放在 test/resources 目录下..还有很多事情,我从头到尾尽了一切可能,但没有什么能帮助我。 我在底部分享了@98​​7654321@。 这是我遇到的问题-

-----------问题/错误 -------------- -------------------------------------------

1 个场景 (�[33m1 undefined�[0m) 3 步 (�[33m3 undefined�[0m) 0m0.000s

您可以使用下面的 sn-ps 实现缺少的步骤:

    @given("^User is already on login page$")
    public void user_is_already_on_login_page() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
   }

 @when("^title of login page is Free CRM$")
   public void title_of_login_page_is_Free_CRM() throws Throwable {
   // Write code here that turns the phrase above into concrete actions
   throw new PendingException();
}

@then("^user enters username and password$")
public void user_enters_username_and_password() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}

项目在 git hub 上可用 -

https://github.com/GarimaKoushik/com.CRM.cucumber.git

【问题讨论】:

  • 您是否尝试过设置glue="stepDefinition"。 Maven 会自动获取 src\test 文件夹下的测试,所以如果使用 maven 执行,那将是一个更好的选择。
  • 检查我的更新答案

标签: java git cucumber cucumber-jvm


【解决方案1】:

根据您的TestRunner 类代码:您需要在glue 属性中添加包名。 stepDefinition 请将您的功能文件放在文件夹中,而不是放在任何包中。

你可以参考这个链接:-http://toolsqa.com/cucumber/cucumber-options/

请尝试以下代码

package Runner;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(
        features= "src/main/java/Features/",
        glue= {"stepDefinition"},
        monochrome=false

        )

public class TestRunner {

}

【讨论】:

  • 请接受我的回答,以便其他人也可以从中获得帮助
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多