io.restassured.module.scala.extensions
Members list
Value members
Concrete methods
A wrapper around [given] that starts building the request part of the test. E.g.
A wrapper around [given] that starts building the request part of the test. E.g.
Given(_.params("firstName", "John"))
.When(_.post("/greetXML"))
.Then(res =>
res.statusCode(200)
res.body("greeting.firstName", equalTo("John"))
)
will send a POST request to "/greetXML" with request parameters firstName=John and lastName=Doe and expect that the response body containing JSON or XML firstName equal to John.
Attributes
- Returns
-
A request specification.
- See also
-
io.restassured.RestAssured.given
A wrapper around [given] that starts building the request part of the test. This is an overloaded version of [Given] that does not take any arguments. E.g.
A wrapper around [given] that starts building the request part of the test. This is an overloaded version of [Given] that does not take any arguments. E.g.
Given()
.When(_.post("/greetXML"))
.Then(_.statusCode(200))
will send a POST request to "/greetXML" request parameters and expect that the statusCode 200.
Attributes
- Returns
-
A request specification.
- See also
-
io.restassured.RestAssured.given
Extensions
Extensions
A wrapper around [then] that lets you validate the response. This method returns a ValidatableResponse that lets you chain validation methods or extract values from the response with the Extract method. Usage example:
A wrapper around [then] that lets you validate the response. This method returns a ValidatableResponse that lets you chain validation methods or extract values from the response with the Extract method. Usage example:
Given(_.params("firstName", "John")
.When(_.post("/greetXML"))
.Then(_.body("greeting.firstName", equalTo("John")))
Attributes
- Returns
-
A validatable response
A wrapper around [then] that lets you validate the response. This method is an overloaded version of [Then] that returns Unit so it's automatically picked-up by test frameworks like JUnit which expect tests to return Unit. Usage example:
A wrapper around [then] that lets you validate the response. This method is an overloaded version of [Then] that returns Unit so it's automatically picked-up by test frameworks like JUnit which expect tests to return Unit. Usage example:
Given(_.params("firstName", "John")
.When(_.post("/greetXML"))
.ThenAssert(_.body("greeting.firstName", equalTo("John")))
Attributes
- Returns
-
A validatable response
A wrapper around [ExtractableResponse] that lets you validate the response. Usage example:
A wrapper around [ExtractableResponse] that lets you validate the response. Usage example:
val firstName: String = Given(_.params("firstName", "John")
.When(_.post("/greetXML"))
.Then(_.body("greeting.firstName", equalTo("John")))
.Extract(_.path("greeting.firstName"))
The above code will send a POST request to "/greetXML" with request parameters firstName=John and lastName=Doe and expect that the response body containing JSON or XML firstName equal to John. The response is then validated and the firstName is extracted from the response. The extracted firstName is then returned. The type of the extracted value is needs to be specified as a type parameter.
Attributes
- Returns
-
The extracted value
A wrapper around [ValidatableResponse] that lets you validate the response. Usage example:
A wrapper around [ValidatableResponse] that lets you validate the response. Usage example:
val firstName: String = Given(_.params("firstName", "John")
.When(_.post("/greetXML"))
.Then(_.body("greeting.firstName", equalTo("John")))
.Extract(_.path("greeting.firstName"))
The above code will send a POST request to "/greetXML" with request parameters firstName=John and lastName=Doe and expect that the response body containing JSON or XML firstName equal to John. The response is then validated and the firstName is extracted from the response. The extracted firstName is then returned. The type of the extracted value is needs to be specified as a type parameter.
Attributes
- Returns
-
The extracted value
A wrapper around [io.restassured.RestAssured.when] to start building the DSL expression by sending a request without any parameters or headers etc. E.g.
A wrapper around [io.restassured.RestAssured.when] to start building the DSL expression by sending a request without any parameters or headers etc. E.g.
Given()
.When(_.get("/x"))
.Then(_.body("x.y.z1", equalTo("Z1")))
Note that if you need to add parameters, headers, cookies or other request properties use the Given method.
Attributes
- Returns
-
A request sender interface that let's you call resources on the server
- See also
-
io.restassured.RestAssured.when