Rest Assured Automation Framework with TestNG and Cucumber integration, along with multiple reporting tools - Extent Reports, Allure Reports, Maven Cucumber Report and Faker library, Azure Devops, Docker Setup and relevant dependencies.
- Java
- Rest Assured
- TestNG
- Cucumber
- Docker Containerization
- Azure Devops
- Rest Assured with TestNG Framework to test and validate APIs
- Examples on JSON Parsing, OAuth 2.0 Authentication and getting Token, GET, POST, PUT, PATCH operations
- Extent Report 5.x for generating Reports for TestNG Test Run
- POJO classes and relevant dto classes for generating Data and using in Tests
- Properties file and relevant classes to utilise it
- TestNG Custom Annotations and RetryAnalyzer listeners
- Sample XML files to run Tests based on Groups/Parallel
- Rest Assured with Cucumber Framework to test and validate APIs
- Examples on Features files, Steps Definations to execute test based on Rest Assured, Runner for TestNG, Hooks and Tags
- Allure Report -> Enabled for Cucumber Execution
- Maven Cucumber Report -> Enabled for Cucumber Execution
- Cucumber Cloud Report -> Enabled for Cucumber Execution
- Dockerfile -> to create the Image of the project, copying relevant JARs and Files and Entrypoint to specify Test Execution
- docker-compose.yaml -> to run the Image in Docker container and getting the test-output to local system by Volume Mapping
- azure-pipelines.yml -> to build the Maven project and run the Tests by specifying the testNG xml suite and build and push the Docker image to repository
- pom.xml -> maven pom.xml specifying all the dependencies and plugins for goals, reports and running the specified testNG xml suite on runtime (locally/jenkins/azuredevops)
- TestNG XML -> XMLs for regular testNG tests and Cucumber tests
- Examples on PropertiesFile to read values from config.properties file, ENUM to pass value to properties method, RestAssured logging, JSONPath wrapper classes
- Parallel Execution Examples for Cucumber Tests
- Excel Read/Write
- Email APIs to send Reports
- Jenkinsfile -> for creating and pushing Image to Docker repository
- mvn test command won't work due to surefire plugin which requires testNG xml suite to be selected, will throw this error Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test failed: testSuiteXmlFiles0 has null value
- Maven commands to run Cucumber classes like mvn test –DCucumber.options="Your Options" won't run due to beforementioned issue
- Test Failures on parallel mode(Thread safety and code optimization for parallel execution is not done)
- Maven Command to Prepare Jars before running Dockerfile -> mvn clean package -DskipTests
- To Build Docker Image, run command: "docker build -t preferredImageName:latest ." "docker build -t rest-assured-apis:latest ."
- StudenAPITest -> requires Docker Image to be running on local to hit the API Endpoints
- Run command -> docker pull tejasn1/student-app
- Run command -> docker run -p 8085:8080 -d tejasn1/student-app
- Check the link for additional instructions to setup
- Maven Command to Execute TestNG xml suite to run TestNG Tests -> mvn clean package test -DsuiteXmlFile=xml-suites/$TESTSUITE; replace $TESTSUITE with the xml name
- Maven Command to Execute TestNG xml suite to run Cucumber classes -> mvn test -DsuiteXmlFile=xml-suites/$TESTSUITE; replace $TESTSUITE with the xml name for Cucumber classes
- Maven Command to generate jars for Docker image -> mvn clean package -DskipTests
- Maven Cucumber HTML Report
- Run Maven Command - mvn test -DsuiteXmlFile=xml-suites/$TESTSUITE verify; replace $TESTSUITE with the TestNG xml containing Cucumber classes
- The POM Plugin defines the report generation phase as verify hence verify is appended to above step, this phase can be changed to test,compile etc
- The Report by default will be generated under target/cucumber-html-reports
- Only available through Maven Run
- Allure Reports for Cucumber
- Run Maven Command - ***mvn test -DsuiteXmlFile=xml-suites/$TESTSUITE ***; replace $TESTSUITE with the TestNG xml containing Cucumber classes
- Run Command In Terminal to check Allure Reports post Cucumber Tests -> allure serve allure-results
- Also available when Runner class is selected and test is Run
- Cucumber Report
- Run Maven Command - ***mvn test -DsuiteXmlFile=xml-suites/$TESTSUITE ***; replace $TESTSUITE with the TestNG xml containing Cucumber classes
- Post run the URL will be visible in the Terminal along with the URL
- The Report by default will be generated under target/JsonReports/cucumber.html; the path is specified in pom and cucumberrunner class
- Also, available when Runner class is selected and test is Run
- Extent Reports for TestNG Runs
- Run Maven Command - ***mvn test -DsuiteXmlFile=xml-suites/$TESTSUITE ***; replace $TESTSUITE with the TestNG xml containing TestNG Tests
- Post Run the report will be generated under test-reports, configurable via properties and Extent Report implementation
- Also, available when Tests are selected and run, individually or class level
- DockerCompose command -> docker-compose up to run the Container and automatically execute the Tests(as specified in the Entrypoint) for the specified Image(in this case the image built using Dockerfile which is present locally)
- Volume Mapping in Dockercompose -> Specify the local system path for which the test-output directory from the container will be copied
- Specifying Env variables in Dockercompose -> The Env variables that is required for Entrypoint(as specified in Dockerfile) is read from the .env file, change the parameters as per requirement
- mvn test - will throw error since the surefire plugin in POM expect TestNG XML file to be specified
- Test-output is not getting copied to Local system -> Check Volume Mappings in Docker compose file as per the Local Environment
- suiteXMLFile is getting null on running docker compose -> Check correct parameter/xml file is specified in .env file which is used by docker-compose file for Environment variables
- Tests Not Running on Docker Compose file ->
- Check if any project related additional files like properties are not copied to Docker Image, any changes in Entrypoint needs to be cross checked in docker-compose file
- Check if the ENTRYPOINT specified in Dockercompose is proper or not
- Running Docker Image in Interactive Mode -> Comment out Entrypoint with #, use the command "docker run -it ", ex: "docker run -it rest-assured-apis" to verify if all dependent Jars and files are copied
- Tests not hitting the Endpoints -> API endpoints for the Tests are hosted by 3rd parties, possibly they could have been shut down or have been changed, please check free APIs from any-api, reqres to practice
Special Thanks to many Instructors who have done a splendid job on explaining and designing framework
- Rahul Shetty
- Rahul Arora
- And many more from which I learnt trouble-shooting points for Jenkins, Dockers, etc through YouTube, StackOverFlow and Articles