Karate
🥋 en tests d’API REST @NicolasComet
https://github.com/ncomet
@binout
https://github.com/binout
@Test
public void should_process_order_and_then_cancel() throws Exception {
// Create new Order
final String orderId = IntegrationTestCase.newProductOrderId();
// Process Order
final Response response = IntegrationTestCase.newClient().path("/product-orders/" + orderId)
.request()
.put(Entity.json("{\"reference\" : \"ABTYD\"}"));
assertThat(response.getStatusInfo()).isEqualTo(Status.OK);
// Cancel Order
final Response response = IntegrationTestCase.newClient().path("/product-orders/" + orderId)
.request()
.delete();
assertThat(response.getStatusInfo()).isEqualTo(Status.NO_CONTENT);
}
@Test
public void lotto_resource_returns_200_with_expected_id_and_winners() {
when().
get("/lotto/{id}", 5).
then().
statusCode(200).
body("lotto.lottoId", equalTo(5),
"lotto.winners.winnerId", containsOnly(23, 54));
}
Web-Services Testing Made Simple.Peter Thomas (Intuit)
https://github.com/intuit/karate (+500 )
@KarateDSL
0.1.2
)0.7.0
https://cfp.devoxx.fr/
java -jar karate.jar -t cfp-speaker.feature
DSL Gherkin
pour écrire des tests d’APIs HTTP MAIS ce n’est pas du BDD !
🤔 Consumer Driven Contracts
Le code et les slides : /binout/karate-devoxxfr2018
/