cucumber-rest-helper

A collection of helper classes for testing REST APIs using cucumber-jvm

License

License

MIT
Categories

Categories

Cucumber Application Testing & Monitoring
GroupId

GroupId

de.leanovate.cucumber
ArtifactId

ArtifactId

rest-helper
Last Version

Last Version

0.9
Release Date

Release Date

Type

Type

jar
Description

Description

cucumber-rest-helper
A collection of helper classes for testing REST APIs using cucumber-jvm
Project URL

Project URL

https://github.com/leanovate/cucumber-rest-helper
Source Code Management

Source Code Management

https://github.com/leanovate/cucumber-rest-helper

Download rest-helper

How to add to project

<!-- https://jarcasting.com/artifacts/de.leanovate.cucumber/rest-helper/ -->
<dependency>
    <groupId>de.leanovate.cucumber</groupId>
    <artifactId>rest-helper</artifactId>
    <version>0.9</version>
</dependency>
// https://jarcasting.com/artifacts/de.leanovate.cucumber/rest-helper/
implementation 'de.leanovate.cucumber:rest-helper:0.9'
// https://jarcasting.com/artifacts/de.leanovate.cucumber/rest-helper/
implementation ("de.leanovate.cucumber:rest-helper:0.9")
'de.leanovate.cucumber:rest-helper:jar:0.9'
<dependency org="de.leanovate.cucumber" name="rest-helper" rev="0.9">
  <artifact name="rest-helper" type="jar" />
</dependency>
@Grapes(
@Grab(group='de.leanovate.cucumber', module='rest-helper', version='0.9')
)
libraryDependencies += "de.leanovate.cucumber" % "rest-helper" % "0.9"
[de.leanovate.cucumber/rest-helper "0.9"]

Dependencies

compile (7)

Group / Artifact Type Version
info.cukes : cucumber-java jar 1.2.4
org.apache.httpcomponents : fluent-hc jar 4.5.1
com.fasterxml.jackson.core : jackson-core jar 2.6.3
com.fasterxml.jackson.core : jackson-databind jar 2.6.3
com.fasterxml.jackson.datatype : jackson-datatype-jdk8 jar 2.6.3
org.assertj : assertj-core jar 3.2.0
org.jsoup : jsoup jar 1.8.3

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Helper classes to test REST service using cucumber-jvm

This is only supposed to work with: Cucumber JVM

The main party trick is that all HTTP requests are recorded and added to the cucumber report so that it is obvious what is happening.

Usage

Take a look in /examples or Book DB example for a full setup.

pom.xml

<dependency>
    <groupId>de.leanovate.cucumber</groupId>
    <artifactId>rest-helper</artifactId>
    <version>0.9</version>
    <scope>test</scope>
</dependency>

Ensure that you include classpath:de/leanovate/cucumber in your glue path. Like this:

@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"pretty", "html:target/cucumber"}, tags = {"~@ignore"},
        glue = {"classpath:your/glue/package", "classpath:de/leanovate/cucumber"})
public class RunCukesTest {
}

Now you can inject the TestHttpClient into your stepdefs:

import de.leanovate.cucumber.rest.TestHttpClient;
import org.apache.http.client.fluent.Request;

import static de.leanovate.cucumber.rest.RestAssertions.assertThat;

public class MyStepdefs {
    private final TestHttpClient client;
    
    public MyStepdefs(TestHttpClient client) {
    	  this.client = client;
    }
    
    @When("^Get the thing$")
    public void get_the_thing() throws Throwable {
        Request request = Request.Get("http://localhost/thing");
    		
        HttpResponse response = client.execute(request);
        
        assertThat(response).isOk();
    }
}
de.leanovate.cucumber

Versions

Version
0.9