我已经开始了一个“放心cucumber”课程,我正在努力完成第一个视频练习。由于某些原因,我无法创建特征文件来查找步骤定义文件。我已经检查了glue选项值是否设置为正确的包名。
除此之外,我还看到,当我试图从功能文件中设置新的步骤定义,并将光标放在路径值上时,会显示一条错误消息:“错误的步骤定义目录路径”。此错误与所有目录值一起显示。
我正在使用IntelIJ 2020.2.3,我已经安装了插件:-Groovy的cucumber。-Java的cucumber。-小cucumber。-静态编程语言。-SubSteps IntellIJ插件
这是pom.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>Rest_Assured_Tests</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>3.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>6.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>gherkin</artifactId>
<version>3.2.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
这是功能文件:
Feature:
This feature video is based in the scenario described in the video (https://www.youtube.com/watch?v=Inwycw_Cpzk&list=PL6tu16kXT9PpgqfMbMdzUzDenYgb0gbk0&index=3&ab_channel=ExecuteAutomation)
Verify GET operations using Rest-Assured
Scenario: Verify author of the post
Given I perform Get operation for "\posts"
When I perform Get for the post number "1"
Then I should see the author name as "Karthik KK"
这是步骤定义:
package step_definitions;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.When;
import io.cucumber.java.en.Then;
import static io.restassured.RestAssured.given;
import static io.restassured.RestAssured.when;
import static org.hamcrest.Matchers.*;
import io.restassured.http.ContentType;
public class Video3 {
@Given("^I perform Get operation for \"([^\"]*)\"$")
private void iPerformGetOperationFor(String url) throws Throwable {
given().contentType(ContentType.JSON);
}
@When("^I perform Get for the post number \"([^\"]*)\"$")
private void iPerformGetForPostNumber(String postNumber) throws Throwable {
when().get(String.format("https://localhost:3000/posts/%s", postNumber)).then().body("author", is("Karthik KK"));
}
@Then("^Then I should see the author name as \"([^\"]*)\"$")
private void iSeeAuthorAs(String name) throws Throwable {
}
}
...这是堆栈跟踪错误
Testing started at 15:44 ...
"C:\Program Files\Java\jdk1.8.0_171\bin\java.exe" -Dorg.jetbrains.run.directory=C:\Users\General\IdeaProjects\Rest_Assured_Tests\src\test\java\features "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2.3\lib\idea_rt.jar=51229:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_171\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\rt.jar;C:\Users\General\IdeaProjects\Rest_Assured_Tests\target\test-classes;C:\Users\General\.m2\repository\io\rest-assured\rest-assured\3.1.1\rest-assured-3.1.1.jar;C:\Users\General\.m2\repository\org\codehaus\groovy\groovy\2.4.12\groovy-2.4.12.jar;C:\Users\General\.m2\repository\org\codehaus\groovy\groovy-xml\2.4.12\groovy-xml-2.4.12.jar;C:\Users\General\.m2\repository\org\apache\httpcomponents\httpclient\4.5.3\httpclient-4.5.3.jar;C:\Users\General\.m2\repository\org\apache\httpcomponents\httpcore\4.4.6\httpcore-4.4.6.jar;C:\Users\General\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;C:\Users\General\.m2\repository\commons-codec\commons-codec\1.9\commons-codec-1.9.jar;C:\Users\General\.m2\repository\org\apache\httpcomponents\httpmime\4.5.1\httpmime-4.5.1.jar;C:\Users\General\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;C:\Users\General\.m2\repository\org\hamcrest\hamcrest-library\1.3\hamcrest-library-1.3.jar;C:\Users\General\.m2\repository\org\ccil\cowan\tagsoup\tagsoup\1.2.1\tagsoup-1.2.1.jar;C:\Users\General\.m2\repository\io\rest-assured\json-path\3.1.1\json-path-3.1.1.jar;C:\Users\General\.m2\repository\org\codehaus\groovy\groovy-json\2.4.12\groovy-json-2.4.12.jar;C:\Users\General\.m2\repository\io\rest-assured\rest-assured-common\3.1.1\rest-assured-common-3.1.1.jar;C:\Users\General\.m2\repository\io\rest-assured\xml-path\3.1.1\xml-path-3.1.1.jar;C:\Users\General\.m2\repository\org\apache\commons\commons-lang3\3.4\commons-lang3-3.4.jar;C:\Users\General\.m2\repository\javax\xml\bind\jaxb-api\2.2.12\jaxb-api-2.2.12.jar;C:\Users\General\.m2\repository\io\cucumber\cucumber-java\6.8.1\cucumber-java-6.8.1.jar;C:\Users\General\.m2\repository\io\cucumber\cucumber-core\6.8.1\cucumber-core-6.8.1.jar;C:\Users\General\.m2\repository\io\cucumber\cucumber-gherkin\6.8.1\cucumber-gherkin-6.8.1.jar;C:\Users\General\.m2\repository\io\cucumber\cucumber-gherkin-messages\6.8.1\cucumber-gherkin-messages-6.8.1.jar;C:\Users\General\.m2\repository\io\cucumber\messages\13.1.0\messages-13.1.0.jar;C:\Users\General\.m2\repository\io\cucumber\tag-expressions\3.0.0\tag-expressions-3.0.0.jar;C:\Users\General\.m2\repository\io\cucumber\cucumber-expressions\10.3.0\cucumber-expressions-10.3.0.jar;C:\Users\General\.m2\repository\io\cucumber\datatable\3.5.0\datatable-3.5.0.jar;C:\Users\General\.m2\repository\io\cucumber\cucumber-plugin\6.8.1\cucumber-plugin-6.8.1.jar;C:\Users\General\.m2\repository\io\cucumber\docstring\6.8.1\docstring-6.8.1.jar;C:\Users\General\.m2\repository\io\cucumber\html-formatter\9.0.0\html-formatter-9.0.0.jar;C:\Users\General\.m2\repository\io\cucumber\create-meta\2.0.2\create-meta-2.0.2.jar;C:\Users\General\.m2\repository\org\apiguardian\apiguardian-api\1.1.0\apiguardian-api-1.1.0.jar;C:\Users\General\.m2\repository\io\cucumber\gherkin\3.2.0\gherkin-3.2.0.jar;C:\Users\General\.m2\repository\io\cucumber\gherkin-jvm-deps\1.0.4\gherkin-jvm-deps-1.0.4.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2.3\plugins\junit\lib\junit-rt.jar;C:\Users\General\AppData\Roaming\JetBrains\IdeaIC2020.2\plugins\cucumber-java\lib\cucumber-jvmFormatter.jar;C:\Users\General\AppData\Roaming\JetBrains\IdeaIC2020.2\plugins\cucumber-java\lib\cucumber-jvmFormatter5.jar;C:\Users\General\AppData\Roaming\JetBrains\IdeaIC2020.2\plugins\cucumber-java\lib\cucumber-jvmFormatter4.jar;C:\Users\General\AppData\Roaming\JetBrains\IdeaIC2020.2\plugins\cucumber-java\lib\cucumber-jvmFormatter3.jar" io.cucumber.core.cli.Main --plugin org.jetbrains.plugins.cucumber.java.run.CucumberJvm5SMFormatter --glue step_definitions C:/Users/General/IdeaProjects/Rest_Assured_Tests/src/test/java/features/Video3.feature
Step undefined
You can implement missing steps with the snippets below:
@Given("I perform Get operation for {string}")
public void i_perform_get_operation_for(String string) {
// Write code here that turns the phrase above into concrete actions
throw new io.cucumber.java.PendingException();
}
Step skipped
Step skipped
Undefined scenarios:
file:///C:/Users/General/IdeaProjects/Rest_Assured_Tests/src/test/java/features/Video3.feature:5# Verify author of the post
1 Scenarios (1 undefined)
3 Steps (2 skipped, 1 undefined)
0m0,644s
You can implement missing steps with the snippets below:
@Given("I perform Get operation for {string}")
public void i_perform_get_operation_for(String string) {
// Write code here that turns the phrase above into concrete actions
throw new io.cucumber.java.PendingException();
}
@When("I perform Get for the post number {string}")
public void i_perform_get_for_the_post_number(String string) {
// Write code here that turns the phrase above into concrete actions
throw new io.cucumber.java.PendingException();
}
@Then("I should see the author name as {string}")
public void i_should_see_the_author_name_as(String string) {
// Write code here that turns the phrase above into concrete actions
throw new io.cucumber.java.PendingException();
}
胶水值在此输入图像描述
当我试图从功能文件中设置新的步骤定义时,会显示错误消息:在此处输入图像描述
最后,我终于意识到我做错了什么。步骤定义文件中的方法需要是公共的,而不是私有的。这是因为功能文件无法访问任何方法。
我不能为一个项目用cucumber执行简单的测试。我在Intellij13社区,使用cucumber插件。 我在features目录中编写了我的features文件,我还通过插件实现了创建它们的步骤。intellij可以识别功能文件中的我的步骤,它可以导航并转到步骤实现。当我尝试运行我的场景时,if无法声明“未定义的步骤”。任何帮助都将不胜感激。 以下是我如何组织我的项目:
我今天将我的serenity和cucumber测试升级到2.6.0 en cucumber 6版本。只需要更改大量程序包,并且功能文件的步骤不再链接到步骤定义。如果我的cucumberrunner的设置 但是,如果我在功能文件中查看intellij,您将无法再单击步骤以转到定义。当我运行功能文件时,我会得到以下异常: 我不确定是什么地方出了问题,因为相同的代码适用于以前的版本
我遇到了以下问题。我在Intellij中有四个Cucumber特性文件。我通过IntelliJ插件添加了Cucumber支持。在创建了特性之后,我按如下所示编辑了配置,这样我就可以执行特性文件了。 可悲的是,当我尝试使用步骤定义运行cucumber特性时,我得到的提示是“您可以使用下面的代码片段实现缺少的步骤:”但我已经这样做了。我已经将这些片段复制到步骤定义文件中。当我悬停一个场景时,Intel
TL:DR控制台不显示缺少步骤的步骤正则表达式 编辑:添加功能文件
我对Cucumber JVM无法获取步骤定义有问题。我在Runner文件中确实有@CucumberOptions。我的功能文件也有@SmokeTest标签。这个问题仍然存在。请帮助!我已经尝试解决这个问题几天了。 Maven 和 Java 版本: Apache Maven 3.0.4Java版本:1.6.0_65,供应商:Apple Inc. 项目结构: 演示-- 运行器文件: 包com.smok
我们在整个测试套件中有200多个特性和2000多个场景。它工作得很好,但许多步骤定义没有使用,我们想删除它们。 目前,我们很难手动尝试删除步骤定义代码,看看这样做是否破坏了什么。是否有一个工具或实用程序可以识别Java-Cucumber代码库中的哪些步骤定义未被使用,以便将其删除?