Beginner Chapter 2 · 10 min read

Setup & Project Structure

Install dependencies, configure your project structure, and set up a clean API testing workspace in Java, JavaScript, and Python.

Setting Up Your API Testing Project

A well-organized project structure is the foundation of maintainable API tests. Each language has its own conventions for project layout, dependency management, and test execution. Let's set up all three.

Java with RestAssured

Java projects typically use Maven or Gradle for dependency management. We'll use Maven with TestNG as the test runner. RestAssured integrates seamlessly with both JUnit and TestNG, and supports Hamcrest matchers for fluent assertions.

JavaScript with Fetch

Node.js 18+ includes the Fetch API natively. We'll use a standard npm project with a test framework like Mocha or Jest. The project setup is minimal since Fetch requires no additional HTTP library.

Python with Requests

Python projects use pip for package management. We'll use pytest as the test runner alongside the requests library. Python's simplicity makes it an excellent choice for API testing — minimal boilerplate, maximum readability.

Recommended Folder Structure

Regardless of language, organize your API tests with clear separation of concerns: configuration files, test utilities/helpers, test data, and the actual test files grouped by API endpoint or feature.

package.json
{
  "name": "api-testing-course",
  "version": "1.0.0",
  "description": "API Testing with Fetch",
  "type": "module",
  "scripts": {
    "test": "mocha --recursive tests/**/*.test.js",
    "test:watch": "mocha --watch --recursive tests/**/*.test.js"
  },
  "devDependencies": {
    "mocha": "^10.2.0",
    "chai": "^5.1.0"
  }
}
project-structure.txt
# Recommended project structure
api-testing/
├── package.json
├── config/
│   ├── base.config.js        # Base URLs, timeouts
│   └── env.config.js         # Environment-specific settings
├── helpers/
│   ├── api-client.js         # Reusable fetch wrapper
│   └── test-data.js          # Test data generators
├── tests/
│   ├── users/
│   │   ├── get-users.test.js
│   │   ├── create-user.test.js
│   │   └── update-user.test.js
│   ├── posts/
│   │   └── posts.test.js
│   └── setup.js              # Global test setup
└── reports/                   # Test reports
config/base.config.js
// config/base.config.js
export const config = {
  baseUrl: 'https://jsonplaceholder.typicode.com',
  timeout: 10000,
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  }
};
pom.xml
<?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.apitesting</groupId>
    <artifactId>api-testing-course</artifactId>
    <version>1.0.0</version>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <rest-assured.version>5.4.0</rest-assured.version>
        <testng.version>7.9.0</testng.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>${rest-assured.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>json-path</artifactId>
            <version>${rest-assured.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>json-schema-validator</artifactId>
            <version>${rest-assured.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>${testng.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.10.1</version>
        </dependency>
    </dependencies>
</project>
project-structure.txt
# Recommended project structure
api-testing/
├── pom.xml
├── src/
│   └── test/
│       ├── java/com/apitesting/
│       │   ├── base/
│       │   │   └── BaseTest.java       # Base config
│       │   ├── models/
│       │   │   └── User.java           # POJOs
│       │   ├── tests/
│       │   │   ├── UserTests.java
│       │   │   └── PostTests.java
│       │   └── utils/
│       │       ├── ApiHelper.java
│       │       └── TestDataBuilder.java
│       └── resources/
│           ├── testng.xml
│           └── config.properties
└── reports/
requirements.txt
# requirements.txt
requests==2.31.0
pytest==8.1.0
pytest-html==4.1.0
python-dotenv==1.0.0
jsonschema==4.21.0
faker==24.0.0
project-structure.txt
# Recommended project structure
api-testing/
├── requirements.txt
├── pytest.ini
├── config/
│   ├── __init__.py
│   ├── base_config.py         # Base URLs, timeouts
│   └── env_config.py          # Environment settings
├── helpers/
│   ├── __init__.py
│   ├── api_client.py          # Reusable request wrapper
│   └── test_data.py           # Test data generators
├── tests/
│   ├── __init__.py
│   ├── conftest.py            # Pytest fixtures
│   ├── test_users.py
│   └── test_posts.py
└── reports/
config/base_config.py
# config/base_config.py

class Config:
    BASE_URL = 'https://jsonplaceholder.typicode.com'
    TIMEOUT = 10
    HEADERS = {
        'Content-Type': 'application/json',
        'Accept': 'application/json'
    }

class TestConfig(Config):
    """Override for test environment"""
    BASE_URL = 'https://jsonplaceholder.typicode.com'

class StagingConfig(Config):
    """Override for staging"""
    BASE_URL = 'https://staging-api.example.com'

API Testing Beginner Setup & Project Structure

Written by PV

© 2026 All Rights Reserved