I am performing an API test using Cucumber and Rest-Assured, but in the call I use Rest-Assured a NullPointer
is being returned.
My Feature:
Scenario: Parâmetros não foram informados
Given A API de teste
When A requisição for realizada sem informar todos os parâmetros
Then A API deve retornar um status code 400
And uma mensagem de erro tratada
Part of my spec:
private Response response;
private ValidatableResponse json;
private RequestSpecification request;
private String ENDPOINT_POST = "https://api-api/algo";
private String TOKEN = "teste";
private String TYPE = "application/json";
@Given("^A API de teste$")
public void a_API_de_teste() {
request = request.with().contentType(TYPE).header("Authorization", TOKEN);
}
At the time of execution of @Given
the following error is being returned:
java.lang.NullPointerException
at steps.CenariosSteps.a_API (ScenariosSteps.java:29)
at? .Given The test API (/src/test/resources/features/cenarios.feature:5)
I could not have any idea what the cause might be, still because the error does not seem be bursting completely.
I'm trying to follow the example of the site:
Rest-Assured with Cucumber: Using BDD for Web Services Automation - Angie Jones
Any suggestions?