Reputation: 1319
Is there a way I can have multiple instances of Rest Assured Client?
I have to test two different endpoints that need:
How can I achieve that? I think Rest Assured is really good, but I am severely limited by its globalness
Are there any design patterns that I can use to get away from this limitation?
Upvotes: 3
Views: 1707
Reputation: 40510
If you don't apply any global configuration statically you can create two different RequestSpecifications. For example:
RequestSpecification spec1 = new RequestSpecBuilder().addHeader("x", "1").setContentType("application/xml").config(RestAssured.config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(..)).build();
RequestSpecification spec2 = new RequestSpecBuilder().addHeader("y", "2").setContentType("application/json").config(RestAssured.config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(..)).build();
// Endpoint 1
given().spec(spec1). ..
// Endpoint 2
given().spec(spec2). ..
Upvotes: 5