Невозможно запустить сценарий огурца ios с помощью intellij и ubuntu, реализовать определения шагов, но они уже реализованы - PullRequest
0 голосов
/ 28 января 2020

Я пытаюсь запустить пример файла функций с парой сценариев огурцов ios, но когда я запускаю их, я получаю, что я не реализовал определение шага, но на самом деле я сделал, у меня есть папка с именем stepDefinitions и внутри java класс с именем StepDefinition, где я написал шаги

 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 огурец из огурца- 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.faster xml .jackson.core jackson-databind 2.10.1

это класс тестового бегуна

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 Cucumber для java 193.5662.7 Gherkin 193.6015.53

1 Ответ

1 голос
/ 03 февраля 2020

Необходимо указать правильный клей в аннотации @CucumberOptions

glue = {"RestAssuredFramework.stepDefinitions"}

glue - имя пакета, в котором хранятся определения шагов

...