https://github.com/leanovate/cucumber-rest-helper
https://github.com/leanovate/cucumber-rest-helper
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/leanovate/cucumber-rest-helper
- Owner: leanovate
- License: mit
- Created: 2016-01-14T08:05:55.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-22T14:46:33.000Z (over 10 years ago)
- Last Synced: 2025-07-05T01:06:04.870Z (11 months ago)
- Language: Java
- Size: 42 KB
- Stars: 1
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Helper classes to test REST service using cucumber-jvm
This is only supposed to work with: [Cucumber JVM](https://github.com/cucumber/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](/examples) or [Book DB example](https://github.com/leanovate/book-db-sample/tree/master/blackbox-tests/cucumber) for a full setup.
`pom.xml`
``` xml
de.leanovate.cucumber
rest-helper
0.9
test
```
Ensure that you include `classpath:de/leanovate/cucumber` in your glue path. Like this:
``` java
@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:
``` java
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();
}
}
```