I have started a course of Rest assured and Cucumber and I am trying to complete the first video exercise. For some reason, I am not able to make my feature file to find the step definition file. I have checked that the glue option value is set with the correct package name.
In addition to that, I have also seen that when I try to set a new step definition from the feature file, and I put the cursor on the path value, an error message is displayed: "Incorrect step definition directory path". This error is displayed with all the directory values.
I am using IntelIJ 2020.2.3 and I have installed the plugins for: -Cucumber for Groovy. -Cucumber for Java. -Gherkin. -Kotlin. -SubSteps IntellIJ plugin
This is the pom.xml file:
<?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>
This is the feature file:
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"
This is the step definition:
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 {
}
}
...and this is the stack trace error
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();
}
Glue value enter image description here
and the error message displayed when I try to set a new step definition from the feature file: enter image description here