首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Cucumber-JVM步骤定义

Cucumber-JVM步骤定义
EN

Stack Overflow用户
提问于 2015-02-13 19:59:40
回答 2查看 9.6K关注 0票数 4

在eclipse中创建了我的特征文件后,我将其作为一个Cucumber特征运行。我使用控制台提供的步骤定义来创建测试文件的第一个基础

代码语言:javascript
复制
@Given("^the input is <(\\d+)> <(\\d+)>$")

这些应该由控制台输出,但是目前它显示的是没有步骤定义的功能。

代码语言:javascript
复制
Feature: this is a test
  this test is to test if this test works right

  Scenario: test runs # src/test/resources/Test.feature:4
    Given: i have a test
    When: i run the test
    Then: i have a working test


0 Scenarios
0 Steps
0m0,000s

此功能只是为了检查cucumber是否正常工作。

跑步者:

代码语言:javascript
复制
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
        monochrome = true,
        dryRun = false,
        format = "pretty",
        features = "src/test/resources/"
        )
public class RunCukes {
}

控制台无法显示所有信息的原因是什么?

TL:DR控制台不显示缺少步骤的步骤正则表达式

编辑:添加的特征文件

代码语言:javascript
复制
Feature: this is a test
  this test is to test if this test works right

  Scenario: test runs
    Given: i have a test
    When: i run the test
    Then: i have a working test
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-02-15 03:23:19

问题出在功能文件中。在给定之后使用,当和然后是问题时使用。我用你的特征文件重现了你的问题。但是,当我删除并运行功能文件时,使用上面提供的相同Runner选项,我得到了实现缺少的步骤定义的正则表达式。

附注:我使用的是IntelliJ,但我不认为这会有什么不同。

代码语言:javascript
复制
  Feature: this is a test
  this test is to test if this test works right

  Scenario: test runs # src/test/resources/Test.feature:4
    Given i have a test
    When i run the test
    Then i have a working test

下面是我得到的结果:

代码语言:javascript
复制
Testing started at 19:12 ...

Undefined step: Given  i have a test

1 Scenarios (1 undefined)
3 Steps (3 undefined)
0m0.000s

Undefined step: When  i run the test

You can implement missing steps with the snippets below:
@Given("^i have a test$")

public void i_have_a_test() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@When("^i run the test$")
public void i_run_the_test() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@Then("^i have a working test$")
public void i_have_a_working_test() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}


Undefined step: Then  i have a working test

1 scenario (0 passed)
3 steps (0 passed)
Process finished with exit code 0
票数 14
EN

Stack Overflow用户

发布于 2017-08-21 08:17:36

如果您的.feature文件不知何故是无效的,就会发生这种情况。我曾经有过这样的经历,因为我的场景大纲的examples表中有两个||组合在一起

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28499135

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档