Coder Social home page Coder Social logo

java-restassured-maven-docker-automation's Introduction

Payconiq Automation task

In this project, the automation framework is created using RestAssured and Java. The tests can be executed locally and also in docker containers.

The task automates the following scenarios in the application [https://restful-booker.herokuapp.com/apidoc/index.html#]-

  • Get booking

    • Get all bookings
    • Get bookings by first name and last name
    • Get bookings by checkin date
    • Get bookings for a valid booking id
    • Get bookings for an invalid booking id
  • Update booking

    • Update booking for a valid booking id
    • Update booking for an invalid request body
    • Update booking for an invalid booking id (Disabled now as the API is not returning the proper response code)
    • Partial update of the booking
  • Delete booking

    • Delete booking for a booking id
    • Delete booking for an invalid booking id (Disabled now as the API is not returning the proper response code)

Built with -

The automation framework used for the task uses the following languages/tools:

  • [Java] - programming language used for the framework
  • [RestAssured] - library used for performing http requests
  • [Junit5] - testing framework used for execution of tests
  • [Maven] - build tool to download and use dependencies
  • [Docker] - open source containerization platform to run tests in containers
  • [Github Actions] - CI/CD tool to run the test scripts which provides quicker feedback
  • [Lombok] - used to generate Getters, Setters and Builders with annotations
  • [Spotless] - used to ensure proper code formatting applied across the project
  • [Assertj] - used to provide readable assertions
  • [Allure] - to generate reports for the tests
  • [Faker] - to generate fake form data

Structure of the framework

Screenshot 2022-01-10 at 11 07 28 AM

How to run the tests?

Pre-requisites - Set the following environment variables for the test to execute

export USER=<email>
export PASSWORD=<password>

Remember to change the export above to SET if you're running a Windows machine.

The tests can be executed in both local machines and docker containers.
To execute tests in local machine -
# Get into the directory
$ cd Payconiq

To run tests in LOCAL machine, execute the following command -

# To execute all tests in local machine
$ mvn spotless:apply clean test

    > 'mvn spotless:apply' is used to ensure proper code formatting is applied across the project and it fixes the same if it is not.

Alternatively, you can also run the following shell script 
$ sh run-tests.sh     
# To execute Get booking tests in local machine
$ mvn spotless:apply clean test -D groups=getBooking  
# To execute Update booking tests in local machine
$ mvn spotless:apply clean test -D groups=updateBooking    
# To execute Delete booking tests in local machine
$ mvn spotless:apply clean test -D groups=deleteBooking  
To execute tests in docker container -

Follow the steps in https://docs.docker.com/get-docker/ to install Docker in your machine.

The Dockerfile contains a shell script file which has the environment variables exported by default.

Dockerfile -

Screenshot 2022-01-10 at 12 19 09 PM

run-tests.sh -

Screenshot 2022-01-10 at 12 16 52 PM

Execute the below commands -

# Build the docker container
$ docker build . -t e2e

$ docker run e2e

$ docker run -e TAG=<tags> e2e
We can run specific tests by passing the <tags> `getBooking` or `updateBooking` or `deleteBooking`

CI/CD

GitHub Actions is the CI/CD tool to execute the tests in docker containers. The pipeline will be triggered for every push made to the repo.

Screenshot 2022-01-10 at 12 57 37 PM

Screenshot 2022-01-10 at 12 58 18 PM

Reporting

Allure framework is used to generate reports for the test execution results. To generate an Allure report post test execution, execute the following command -

$ allure serve 

Screenshot 2022-01-10 at 12 51 47 PM

Checklist

  • Use Builders to generate request body
  • Stability of the tests
  • CI/CD
  • Dockerized execution
  • Have readable assertions to tests
  • Generating human-readable report
  • Generating random values for insignificant data

"Nice to have" that can be done

  • Integration of test scenario with test cases of any test management tool

We can integrate the test execution status with a test management tool like Zephyr using ZAPI.

java-restassured-maven-docker-automation's People

Contributors

sharath2106 avatar

Watchers

 avatar  avatar

Forkers

garinyr

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.