Reputation: 2862
I'm working on a project which receives json data via REST and after some processing sends them further. I.e. it has both HTTP-server and HTTP-client parts.
Now I'm told to add integration tests to them and was proposed to use Citrus framework. I see it has citrus-http module, but after setting all things up I do not feel very happy with it for I do not want write tests in XML (while it is required they should not be written in compiled code).
So I started to think about using JBehave, but I have no experience with testing http with it - and I could not find necessary examples at once. It seems I need to start http server, send some data with http client and check the result on the server. But are there any modules or JBehave-friendly framework for providing this "http" part - or I should create them from scratch?
Upvotes: 0
Views: 1537
Reputation: 2236
Your assumption that Citrus only supports XML tests is wrong. Citrus also provides a Java DSL for writing tests. Here is an example:
@CitrusTest
public void testHttp() {
http().client("http://localhost:8080")
.post()
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.payload("name=Penny&age=20");
http().client("http://localhost:8080")
.response(HttpStatus.OK);
}
JBehave is a BDD (Behavior Driven Development) framework and has nothing to do with Http testing in particular. You can combine any Http test library with JBehave
Upvotes: 0
Reputation: 21
You could use WireMock. It's a library that works really good with http requests. You could start your WireMock server in @BeforeStory
and it will start recording and then shut it down in your @AfterStory
in your steps class. You will have your response for your request stored in a file and it will be easy to work with.
Upvotes: 1