Rest Assured Getting Started
Published in
2 min readJul 24, 2020
REST Assured for Maven users
Maven:
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>4.3.1</version>
<scope>test</scope>
</dependency>
Notes
- You should place rest-assured before the JUnit dependency declaration in your pom.xml / build.gradle in order to make sure that the correct version of Hamcrest is used.
- REST Assured includes JsonPath and XmlPath as transitive dependencies.
TestNG
Maven:
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.1.0</version>
<scope>test</scope>
</dependency>
JsonPath
Standalone JsonPath (included if you depend on the rest-assured
artifact). Makes it easy to parse JSON documents. Note that this JsonPath implementation uses Groovy's GPath syntax and is not to be confused with Kalle Stenflo's JsonPath implementation.
Maven:
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-path</artifactId>
<version>4.3.1</version>
<scope>test</scope>
</dependency>
XmlPath
Stand-alone XmlPath (included if you depend on the rest-assured
artifact). Makes it easy to parse XML documents.
Maven:
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>xml-path</artifactId>
<version>4.3.1</version>
<scope>test</scope>
</dependency>
JSON Schema Validation
If you want to validate that a JSON response conforms to a Json Schema you can use the json-schema-validator
module:
Maven:
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-schema-validator</artifactId>
<version>4.3.1</version>
<scope>test</scope>
</dependency>