Code Monkey home page Code Monkey logo

restassured-framework-setup's Introduction

Running Rest Assured Tests

Rest Assured Architecture Setup Rest Assured Logo

This repository contains the configuration and architecture to create API automated tests using Rest Assured.

The test examples are based on the APIs provided by Reqres.in

Required Software

Libraries used in the project

Environments

By default, the tests use the properties values from the QA environment, but it is possible to change that using the property environment. Check out some possibilities:

run command
local mvn test -Denvironment=local
develop mvn test -Denvironment=dev
qa mvn test -Denvironment=qa

Groups

If you execute mvn test, all the tests will be executed by default.

To run different groups/test suites, you can use the property -D, including the group name. Take a look on some examples:

run command
login tests mvn -Dgroups="login" test
user tests mvn -Dgroups="user" test
all tests mvn test

Groups + Reports

To automatically generate the test report. You can use the command line to generate it in two ways:

  • mvn allure:serve: will open the HTML report into the browser
  • mvn allure:report: will generate the HTML port at target/site/allure-maven-plugin folder

Generated Allure Report

You can also use the profiles to generate reports from a specific test suite:

run command
login report mvn test allure:report -Dgroups="login"
user report mvn test allure:report -Dgroups="user"
all tests report mvn test allure:report

The HTML report is generated in the following path: target > site > allure-maven-plugin > index.html.

Notice that it is possible to select an environment, a group and generate a report with a unique command:

mvn test allure:report -Denvironment=dev -Dgroups="user"

About the Project Structure

baseRequest

Base Test that sets the initial settings to execute requests using RestAssured.

commons

It contains any class that is used in the entire project. For example, it has the HeadersDefinition class that that contains the headers configuration used in all the test requests.

config

The class Configuration loads the property files located in src/test/resources/conf, based on the environment selected for the test run.

@LoadPolicy(LoadType.MERGE)
@Config.Sources({"classpath:conf/${environment}.properties"})
public interface Configuration extends Config{
    ...
}

The environment variable is read on the ConfiguratorManager. This class reduces the amount of code necessary to get any information on the properties file.

This strategy uses Owner library

data/factory

Test Data Factory classes using java-faker to generate fake data and [Lombok] to create the objects using the Builder pattern.

data/provider

JUnit 5 Arguments to reduce the amount of code and maintenance for the functional tests on SimulationsFunctionalTest

data/suite

It contains a class having the data related to the test groups.

data/support

Includes classes to generate data part of pre-conditions for some test cases

data/model

Model and Builder class to map objects thought serialization and deserialization in use with Rest-Assured.

src/test/resources

It has a schemas folder with the JSON Schemas to enable Contract Testing using Rest-Assured. Also, the properties file to easily configure the API URI.

Credits to Elias Nogueira for influencing me with many ideas applied to this project

restassured-framework-setup's People

Contributors

dependabot[bot] avatar renovate-bot avatar renovate[bot] avatar teixeira-fernando avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

teodickson

restassured-framework-setup's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/tests.yml
  • actions/checkout v4
  • actions/setup-java v4
  • scacap/action-surefire-report v1
  • actions/upload-artifact v4
maven
pom.xml
  • io.rest-assured:rest-assured 5.4.0
  • io.rest-assured:json-schema-validator 5.4.0
  • org.junit.jupiter:junit-jupiter 5.10.2
  • org.assertj:assertj-core 3.25.3
  • com.github.javafaker:javafaker 1.0.2
  • org.aeonbits.owner:owner 1.0.12
  • org.apache.logging.log4j:log4j-api 2.23.1
  • org.apache.logging.log4j:log4j-core 2.23.1
  • io.qameta.allure:allure-testng 2.27.0
  • io.qameta.allure:allure-attachments 2.27.0
  • io.qameta.allure:allure-junit5 2.27.0
  • org.slf4j:slf4j-api 2.0.13
  • org.slf4j:slf4j-simple 2.0.13
  • org.projectlombok:lombok 1.18.32
  • org.apache.maven.plugins:maven-surefire-plugin 3.2.5
  • org.aspectj:aspectjweaver 1.9.22
  • io.qameta.allure:allure-maven 2.12.0
  • org.apache.maven.plugins:maven-compiler-plugin 3.13.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.