How I Built a Robust API Test Automation Framework with RestAssured

Sinem Merve Ozdemir
3 min readDec 21, 2024

--

Introduction

In the world of software testing, creating a robust, scalable, and maintainable automation framework is an art. Recently, I had the opportunity to develop an API test automation framework using RestAssured, TestNG, Extent Reports, and GitHub Actions for a technical interview challenge. 🚀

This project allowed me to explore the integration of modern testing tools, build a CI/CD pipeline, and solve real-world problems like reporting and parallel test execution. Here’s how I did it and the lessons I learned along the way!

Step 1: Defining the Scope

The goal was clear:

  1. Develop an automation framework for testing RESTful APIs.
  2. Use tools like RestAssured for API testing and TestNG for execution.
  3. Add detailed HTML reporting using Extent Reports.
  4. Integrate with GitHub Actions for CI/CD automation.
  5. Keep the codebase clean and well-documented.

Step 2: Setting Up the Project

I structured the project to maintain modularity and scalability:

|-- src
| |-- main
| | |-- java
| | |-- com.utils # Utility classes (JsonReader, Logger)
| |-- test
| |-- java
| |-- com.testcases # Test classes
|-- .github
| |-- workflows # CI/CD pipeline configurations
|-- target # Build and test output files
  • Key Tools Used: Java 17, Maven, RestAssured, TestNG.
  • API Under Test: GoREST.

Step 3: Adding Reporting and Logging

I integrated Extent Reports for HTML-based test results and SLF4J Logger for step-by-step execution tracking. This combination allowed for clear visibility into the success or failure of each test case.

Code snippet for logging:

logger.info("Starting test: createUserFromJson");
logger.debug("Loaded users: " + users);

Step 4: Parallel Execution

To optimize test execution time, I enabled parallel test runs in TestNG by modifying the testng.xml configuration. This small change saved significant time during execution.

Step 5: CI/CD Integration

One of the highlights of the project was integrating GitHub Actions for CI/CD. The pipeline:

  1. Sets up JDK 17.
  2. Installs dependencies with Maven.
  3. Executes the tests.
  4. Uploads the Extent Reports as artifacts.

Sample ci.yml:

- name: Run tests
run: mvn test
- name: Upload Extent Reports
uses: actions/upload-artifact@v4
with:
name: extent-report
path: target/ExtentReport.html

Step 6: Overcoming Challenges

Like any project, there were roadblocks:

  1. Dependency Issues: Solved by carefully managing pom.xml versions.
  2. Reporting Failures: Debugged by adding detailed logging.
  3. CI/CD Errors: Fixed by updating deprecated configurations and testing workflows iteratively.

Outcome

After completing the framework, I was able to:

  1. Achieve dynamic data reading for tests.
  2. Generate detailed reports for better insights.
  3. Automate testing workflows through CI/CD pipelines.
  4. Reduce test execution time with parallel runs.

This project not only showcased my technical skills but also boosted my confidence in tackling complex test automation scenarios. 🎉

Takeaways

Building a robust framework requires a mix of technical knowledge, problem-solving skills, and perseverance. Whether you’re preparing for an interview or improving your test processes, remember:

  • Plan your project structure.
  • Choose the right tools for the job.
  • Log every step and document your journey.
  • Automate wherever possible.

Closing Thoughts

This project was an enriching experience that helped me grow as a test automation engineer. If you’re interested in diving deeper into the project, feel free to check out my GitHub repository here. 💻

That’s all I’m going to talk about for now. See you in my next post!

Until then,
#HappyTesting ❤️

--

--

Sinem Merve Ozdemir
Sinem Merve Ozdemir

Responses (2)