Cucumber Undefined Step, Though Defined Using IntelliJ(黄瓜未定义步骤,虽然使用 IntelliJ 定义)
问题描述
我正在尝试运行一个 .feature 文件来测试一个简单的 RESTEasy Web 应用程序:
有时会在保存对包的旧名称的引用时发生.如果包已重命名,您应该检查是否有对旧名称(Cucumber 运行/调试配置)的引用并删除它们.
亲切的问候
I'm trying to run a .feature file to test a simple RESTEasy web application: https://github.com/dashorst/jaxrs-quickstart-resteasy.
However, the IntelliJ keeps saying that:
Undefined step: Given I am an invalid username
Undefined step: When I perform a hello request with null username
Undefined step: Then I receive a http response code of 400
Undefined step: When I perform a hello request with empty username
Undefined step: Then I receive a http response code of 400
You can implement missing steps with the snippets below:
@Given("^I am an invalid username$")
public void I_am_an_invalid_username() throws Throwable {
// Express the Regexp above with the code you wish you had
throw new PendingException();
}
// similar results...
Below is my hello.feature
file:
Feature: hello
#-------------------------------------
#next block is got the GET entry point
#-------------------------------------
#verify that with malformed input hello fails
Scenario: invalid username should fail
Given I am an invalid username
When I perform a hello request with null username
Then I receive a http response code of 400
When I perform a hello request with empty username
Then I receive a http response code of 400
#verify that you can get correct hello response with valid username. This is the 'everything works fine' path.
Scenario: User can get correct hello response with valid username
Given I am a valid username
When I perform a hello request with valid username
Then I receive a http response code of 200
import cucumber.annotation.en.Given;
import cucumber.annotation.en.Then;
import cucumber.annotation.en.When;
import cucumber.runtime.PendingException;
I used IntelliJ option "generate steps" and got the MyStepdefs
file.
/**
* Created by z on 5/21/17.
*/
public class MyStepdefs {
@Given("^I am a valid username$")
public void iAmAValidUsername() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Given("^I am an invalid username$")
public void iAmAnInvalidUsername() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@When("^I perform a hello request with null username$")
public void iPerformAHelloRequestWithNullUsername() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Then("^I receive a http response code of (\d+)$")
public void iReceiveAHttpResponseCodeOf(int arg0) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@When("^I perform a hello request with empty username$")
public void iPerformAHelloRequestWithEmptyUsername() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@When("^I perform a hello request with valid username$")
public void iPerformAHelloRequestWithValidUsername() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
}
I had tried to specify glue path for each scenario, but it doesn't work. I'm not sure what went run. Thanks for any advice!
I have looked into several existing questions but none of them helps:
Cucumber: undefined step, although step should be defined
Cucumber JVM undefined step
This is my project structure:
Sometimes it happens when there are saved references to the old names of the packages. If the packages have been renamed you should check if there are references to the old names (Cucumber Run/Debug Configurations) and delete them.
Kind regards
这篇关于黄瓜未定义步骤,虽然使用 IntelliJ 定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:黄瓜未定义步骤,虽然使用 IntelliJ 定义
基础教程推荐
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- 在螺旋中写一个字符串 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01