Before you write a single test, you need a project. REST Assured is a Maven dependency. You add it to pom.xml and Maven downloads everything. No installers. No setup wizards. Just XML.
Open IntelliJ IDEA. Click "New Project."
Select "Maven Archetype" on the left. Choose maven-archetype-quickstart.
Set GroupId: com.yourcompany, ArtifactId: api-tests.
Click Create. IntelliJ generates the project structure.
Open pom.xml. This is where you add dependencies.
Replace the contents with the pom.xml shown below.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.yourcompany</groupId>
<artifactId>api-tests</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<rest-assured.version>5.4.0</rest-assured.version>
<testng.version>7.9.0</testng.version>
</properties>
<dependencies>
<!-- REST Assured -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>${rest-assured.version}</version>
<scope>test</scope>
</dependency>
<!-- TestNG -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
<!-- Hamcrest (comes with REST Assured, but explicit is better) -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<!-- Jackson for JSON serialization/deserialization -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.0</version>
<scope>test</scope>
</dependency>
<!-- JSON Schema Validator -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-schema-validator</artifactId>
<version>${rest-assured.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
</plugin>
</plugins>
</build>
</project>| Dependency | Purpose | Why You Need It |
|---|---|---|
| rest-assured | HTTP client with BDD syntax | The star of the show — sends requests, validates responses |
| testng | Test framework | Provides @Test, @BeforeClass, assertions, test suites |
| hamcrest | Matcher library | equalTo(), hasSize(), containsString() — readable assertions |
| jackson-databind | JSON to Java object mapping | Serialize POJOs to JSON, deserialize responses to POJOs |
| json-schema-validator | Schema validation | Validate response JSON against a schema file |
| maven-surefire-plugin | Test runner plugin | Runs TestNG tests via mvn test command |
api-tests/
├── pom.xml
├── src/
│ ├── main/java/ # Not used for tests — leave empty
│ └── test/
│ ├── java/
│ │ └── com/yourcompany/
│ │ ├── tests/
│ │ │ ├── GetRequestsTest.java
│ │ │ ├── PostRequestsTest.java
│ │ │ └── CRUDTest.java
│ │ ├── pojo/
│ │ │ └── Post.java
│ │ └── base/
│ │ └── BaseTest.java
│ └── resources/
│ └── schemas/
│ └── post-schema.jsonAll test files go under src/test/java, NOT src/main/java. Maven only runs tests from the test directory. If you put your test class in src/main, mvn test will not find it. This is the most common beginner mistake.
After adding the dependencies, right-click pom.xml in IntelliJ and select "Maven > Reload Project." Or run this from terminal:
# Download all dependencies
mvn clean install -DskipTests
# Verify everything is downloaded
mvn dependency:treeUse version properties in pom.xml (like ${rest-assured.version}) instead of hardcoding versions in each dependency. When you upgrade, you change one line instead of hunting through the file.
Q: What dependencies do you need for a REST Assured project?
A: At minimum: rest-assured for the HTTP client, testng (or junit) for the test framework, and hamcrest for matchers. For real projects, I also add jackson-databind for POJO serialization/deserialization, json-schema-validator for response schema validation, and maven-surefire-plugin for running tests via mvn test. All dependencies go in pom.xml with scope test since they are only needed during testing, not in production.
Key Point: Create a Maven project with rest-assured, testng, hamcrest, jackson-databind, and json-schema-validator. All dependencies go in pom.xml with scope test. Tests live under src/test/java.