无法 运行 使用 intellij 和 ubuntu 的黄瓜方案,实现步骤定义,但它们已经实现

Unable to run cucumber scenarios using intellij and ubuntu, implement step definitions but they are already implemented

我正在尝试 运行 一个包含几个黄瓜场景的示例特征文件,但是当我 运行 他们时,我发现我没有实现步骤定义,但我确实做到了,我有一个名为 stepDefinitions 的文件夹,在一个名为 StepDefinition 的 java class 中,我在其中编写了步骤

 Testing started at 20:14 ... 
Undefined scenarios:
/home/adrianjimenez/IdeaProjects/RestAssured/src/test/java/RestAssuredFramework/features/fileValidations.feature:13 # Verify if Place is being Successfully added using AddPlaceAPI
/home/adrianjimenez/IdeaProjects/RestAssured/src/test/java/RestAssuredFramework/features/fileValidations.feature:17 # Verify if Delete Place functionality is working

2 Scenarios (2 undefined)
10 Steps (10 undefined)
0m0.536s


You can implement missing steps with the snippets below:

@Given("Add Place Payload with {string}  {string} {string}")
public void add_Place_Payload_with(String string, String string2, String string3) {
    // Write code here that turns the phrase above into concrete actions
    throw new cucumber.api.PendingException();
}

@When("user calls {string} with {string} http request")
public void user_calls_with_http_request(String string, String string2) {
    // Write code here that turns the phrase above into concrete actions
    throw new cucumber.api.PendingException();
}

@Then("the API call got success with status code {int}")
public void the_API_call_got_success_with_status_code(Integer int1) {
    // Write code here that turns the phrase above into concrete actions
    throw new cucumber.api.PendingException();
}

@Then("{string} in response body is {string}")
public void in_response_body_is(String string, String string2) {
    // Write code here that turns the phrase above into concrete actions
    throw new cucumber.api.PendingException();
}

@Then("verify place_Id created maps to {string} using {string}")
public void verify_place_Id_created_maps_to_using(String string, String string2) {
    // Write code here that turns the phrase above into concrete actions
    throw new cucumber.api.PendingException();
}

@Given("DeletePlace Payload")
public void deleteplace_Payload() {
    // Write code here that turns the phrase above into concrete actions
    throw new cucumber.api.PendingException();
}


Process finished with exit code 0

但我实际上执行了这些步骤,所以我不明白发生了什么,这些是我执行的步骤。

package RestAssuredFramework.stepDefinitions;

import RestAssuredFramework.resources.APIResources;
import RestAssuredFramework.resources.TestDataBuilder;
import RestAssuredFramework.resources.Utils;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import io.restassured.builder.ResponseSpecBuilder;
import io.restassured.http.ContentType;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;

import java.io.IOException;

import static io.restassured.RestAssured.given;
import static org.junit.Assert.assertEquals;

public class StepDefinition extends Utils {
    RequestSpecification res;
    String responseString;
   static String place_id;
    ResponseSpecification resspec;
    Response response;
    TestDataBuilder testDataBuilder = new TestDataBuilder();
    JsonPath jsonPath;

    @Given("Add Place Payload with {string}  {string} {string}")
    public void add_Place_Payload_with(String name, String language, String address) throws IOException {
        // Write code here that turns the phrase above into concrete actions
        res=given().spec(requestSpecification())
                .body(testDataBuilder.addPlacePayload(name,language,address));
    }
    @When("user calls {string} with {string} http request")
    public void user_calls_with_http_request(String resource, String method) {
        // Write code here that turns the phrase above into concrete actions
//constructor will be called with value of resource which you pass
        APIResources resourceAPI=APIResources.valueOf(resource);
        System.out.println(resourceAPI.getResource());
        resspec =new ResponseSpecBuilder().expectStatusCode(200).expectContentType(ContentType.JSON).build();

        if(method.equalsIgnoreCase("POST"))
            response =res.when().post(resourceAPI.getResource());
        else if(method.equalsIgnoreCase("GET"))
            response =res.when().get(resourceAPI.getResource());
    }
    @Then("the API call got success with status code {int}")
    public void the_API_call_got_success_with_status_code(Integer int1) {
        // Write code here that turns the phrase above into concrete actions
        assertEquals(response.getStatusCode(),200);
    }
    @Then("{string} in response body is {string}")
    public void in_response_body_is(String keyValue, String Expectedvalue) {
        // Write code here that turns the phrase above into concrete actions

        assertEquals(getJsonPath(response,keyValue),Expectedvalue);
    }

    @Then("verify place_Id created maps to {string} using {string}")
    public void verify_place_Id_created_maps_to_using(String expectedName, String resource) throws IOException {
        // requestSpec
        place_id=getJsonPath(response,"place_id");
        res=given().spec(requestSpecification()).queryParam("place_id",place_id);
        user_calls_with_http_request(resource,"GET");
        String actualName=getJsonPath(response,"name");
        assertEquals(actualName,expectedName);
    }
    //delete scneario
    @Given("DeletePlace Payload")
    public void deleteplace_Payload() throws IOException {
        // Write code here that turns the phrase above into concrete actions
        res =given().spec(requestSpecification()).body(testDataBuilder.deletePlacePayload(place_id));
    }
}

这是我的功能文件

Feature: Validating Place API's
  @AddPlace @Regression
  Scenario Outline: Verify if Place is being Successfully added using AddPlaceAPI
    Given Add Place Payload with "<name>"  "<language>" "<address>"
    When user calls "AddPlaceAPI" with "POST" http request
    Then the API call got success with status code 200
    And "status" in response body is "OK"
    And "scope" in response body is "APP"
    And verify place_Id created maps to "<name>" using "getPlaceAPI"

    Examples:
      |name      | language |address           |
      |peter |  Spanish |Aguascalientes, st|
#   |BBhouse | Spanish  |Sea cross center  |

  @DeletePlace @Regression
  Scenario: Verify if Delete Place functionality is working

    Given DeletePlace Payload
    When user calls "deletePlaceAPI" with "POST" http request
    Then the API call got success with status code 200
    And "status" in response body is "OK"

intellij 版本

IntelliJ IDEA 2019.3.2 (Community Edition)
Build #IC-193.6015.39, built on January 21, 2020
Runtime version: 11.0.5+10-b520.30 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 5.0.0-37-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 725M
Cores: 4
Registry: 
Non-Bundled Plugins: gherkin, cucumber-java

pom.xml

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

<groupId>org.example</groupId>
<artifactId>RestAssured</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.0</version>
    <configuration>
        <source>8</source>
        <target>8</target>
    </configuration>
</plugin>  

UTF-8 7 io.cucumber cucumber-java 4.8.0

<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>4.8.0</version>
    <scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
<dependency>
    <groupId>io.rest-assured</groupId>
    <artifactId>rest-assured</artifactId>
    <version>4.1.2</version>
    <scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind

--> com.fasterxml.jackson.core jackson-databind 2.10.1

这是测试运行ner class

package RestAssuredFramework.cucumber.Options;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
        features = "src/test/java/RestAssuredFramework",
        glue = {"StepDefinition"}

        ) 

public class TestRunner {
}

我在intellij中也安装了以下插件 java 193.5662.7 的黄瓜 小黄瓜 193.6015.53

您需要在@CucumberOptions 注释中提供正确的胶水

glue = {"RestAssuredFramework.stepDefinitions"}

glue - 是存储步骤定义的包名称