Automation Testing | RESTful webservices | Java | RestAssured | OAuth 2.0 | Lombok | TestNG | Maven | ExtentReport | Allure Reports | Java mail API | Design Patterns (Singleton) | Jenkins | Data-Driven Testing using JSON file | Expected Data using XML file

Overview

MasterRestAssuredFramework

With further updates - This project is designed and developed with the help of -

  1. Udemy course (OmPrakash Chavan - REST Assured API Automation + Framework: From Zero to Hero!)
  2. YouTube playlist (Testing Mini Bytes)

image

Updations done:

ExtentReports V5

  1. User can apply the Filters -
  • Author - Rajat, Nishant, Gautam, Pankaj
  • TestType - Smoke, Sanity, Regression, BVT
  1. Screenshots are attached in the ExtentReport as Base64 format. image image

Allure Reports image

User has options for customization image

Email to User(s) using Java mail API image

Others implementations:

  1. Retry failed test cases
  2. Custom Enums, Exceptions, Annotations
  3. Serialization and Deserialization using Jackson-Databind dependency
  4. Zip the ExtentReports directory into Project path (you can send this Zip file as well as an Attachment in Email)
  5. Automatically open the report after tests execution.
  6. Request and Response details added in ExtentReports:
  7. Send EMail using Java mail API to User(s) with attachment(s).

How to run the Project from Local machine

  1. Pull the code into your machine and import in IDE (Eclipse/intelliJ).
  2. Go to testng_Local.xml -> Run this file as TestNG suite It should start the execution -> Parallel Testing.
  • NOTE: stg_config.properties is the default configuration file.
  1. To view the Allure reports
  • Setup the Allure in your machine
  • Go to URL (https://docs.qameta.io/allure/) -> Search for Manual installation -> Steps are mentioned
  • Go to your project location
  • Open command prompt -> allure serve allure-results

How to run the Project from Jenkins __Final-OC_RestAssured-Github-ActiveChoiceParams.pdf image

Email to User(s) using Jenkins:

  1. You can refer: https://www.youtube.com/watch?v=MFgbp00hbVI&ab_channel=Mukeshotwani image

You might also like...

Restful-booker API test automation project using Java and REST Assured.

Restful-booker API Test Automation Restful-booker API is an API playground created by Mark Winteringham for those wanting to learn more about API test

Aug 14, 2022

BDD framework for automation using Selenium Cucumber and TestNg

BDD framework for automation using Selenium Cucumber and TestNg

Selenium Framework with Cucumber BDD framework for automation using Selenium Cucumber and TestNg The framework has following features Modular Design M

Jan 20, 2022

An e-commerce automation project of Selenium TestNG using Page Object Model

An e-commerce automation project of Selenium TestNG using Page Object Model

Selenium-POM-TestNG Prerequisites Install jdk 8 or any LTS version Configure JAVA_HOME and GRADLE_HOME Download Allure 2.17.2 and configure environmen

Aug 4, 2022

TestNG testing framework

Documentation available at TestNG's main web site. Release Notes 7.4.0 7.3.0 7.1.0 7.0.0 Need help? Before opening a new issue, did you ask your quest

Jan 5, 2023

Cucumber DSL for testing RESTful Web Services

Cucumber DSL for testing RESTful Web Services

cukes-rest takes simplicity of Cucumber and provides bindings for HTTP specification. As a sugar on top, cukes-rest adds steps for storing and using r

Oct 18, 2022

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.

pact-jvm JVM implementation of the consumer driven contract library pact. From the Ruby Pact website: Define a pact between service consumers and prov

Dec 31, 2022

JVM version of Pact Enables consumer driven contract testing

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.

Dec 30, 2022

Never debug a test again: Detailed failure reports and hassle free assertions for Java tests - Power Asserts for Java

Never debug a test again: Detailed failure reports and hassle free assertions for Java tests - Power Asserts for Java

Scott Test Reporter for Maven and Gradle Get extremely detailed failure messages for your tests without assertion libraries, additional configuration

Nov 17, 2022
Comments
  • Extend report doesn't display correctly

    Extend report doesn't display correctly

    All the log of whole tests now be in one test.

    This one is empty image

    This one has all image

    I think problem comes from the part writing log to report. I will investigate later, post this issue to note this.

    opened by lucas-nguyen-17 1
  • Doesn't retry failed tests

    Doesn't retry failed tests

    After refactoring setting listeners in testng.xml file, the feature re-run faileds test doesn't work.

    Reason

    @Listeners(value = {AnnotationTransformer.class,
    		ListenerClass.class,
    		MethodInterceptor.class})
    public class _BaseTest {
    

    Any TestNG listeners can be loaded by @Listeners, except IAnnotationTransformer --> AnnotationTransformer.class can't be loaded. Testng need to know IAnnotationTransformer earlier. Issue: https://github.com/cbeust/testng/issues/446

    Solution You can choose one of 2 below approachs (both are tested):

    • in testng.xml file --> have to config for each testng.xml file, and run by testng.xml file
    <listeners>
    	<listener class-name="com.spotify.oauth2.listeners.AnnotationTransformer"/>
    </listeners>
    
    • in maven sure-fire plugin --> have to run through mvn clean test
    <property>
    	<name>listener</name>
    	<value>com.spotify.oauth2.listeners.AnnotationTransformer</value>
    </property>
    

    Two above solutions don't have same effect when running directly from IDE like Intellij.

    Personally, I don't like the idea retry failed tests for API tesing because API based on stable HTTP request, it is not flaky as selenium tests. So it's up to you @rajatt95 , choose one way and I will make a pull request.

    opened by lucas-nguyen-17 1
  • NullPointerException at com.spotify.oauth2.reports.ExtentLogger.info(ExtentLogger.java:39)

    NullPointerException at com.spotify.oauth2.reports.ExtentLogger.info(ExtentLogger.java:39)

    I run the test ShouldBeAbleToCreateAPlaylist, get error NullPointerException. I guess problem here:

    • You only declared a ThreadLocal<ExtentTest> extentTest but haven't created ExtentTest instance and set to this ThreadLocal

    Full stacktrace:

    Re-newing Token........
    Request method:	POST
    Request URI:	https://accounts.spotify.com/api/token
    Proxy:			<none>
    Request params:	<none>
    Query params:	<none>
    Form params:	refresh_token=AQAA4NY58s9oRvQoo6NpPvtZ38BhVu2STD8Fdii1-QIbeXgaYXbkcXo3mnMEdAvMuZvn6tEDXZC9zz1J552Um1N5wfZ4CEkexRb6oy-xCFMvq2_DiNh6SNomzADu85HvU6E
    				grant_type=refresh_token
    				client_secret=fa0a167372fb4d8ebdc84c3db543b92c
    				client_id=568d41bc66f5436cb72d09bb4c6f5f6d
    Path params:	<none>
    Headers:		Accept=*/*
    				Content-Type=application/x-www-form-urlencoded; charset=ISO-8859-1
    Cookies:		<none>
    Multiparts:		<none>
    Body:			<none>
    HTTP/1.1 200 OK
    date: Tue, 19 Oct 2021 02:08:26 GMT
    content-type: application/json
    vary: Accept-Encoding
    set-cookie: __Host-device_id=AQDjOeilHBuheTAMl84-MylXpdjgKw0kz4a6iEN7f2Q_LB0Ji9re9lJln2GrP202ZH7VGN_X7AYzaHSE_ek1cYsqChajB27V3aM;Version=1;Path=/;Max-Age=2147483647;Secure;HttpOnly;SameSite=Lax
    set-cookie: sp_tr=false;Version=1;Domain=accounts.spotify.com;Path=/;Secure;SameSite=Lax
    sp-trace-id: 699dc282eed3c8b1
    content-encoding: gzip
    strict-transport-security: max-age=31536000
    x-content-type-options: nosniff
    server: envoy
    Via: HTTP/2 edgeproxy, 1.1 google
    Alt-Svc: clear
    Transfer-Encoding: chunked
    
    {
        "access_token": "BQDk02Hg1JWicXaVfD8pBTTCGsX-bz6B_lHj9eiX5UBAJ8AcSL73m9Fk1913_hrdSIhCBx5KoFHZFeaxXTmHrLxD5ozytvPTMGFSMWVqk4k6w1bZBHrMWeyPxtlpxQOIb93zp1MpximC6Nbq6jGNV9INahDrwtMo_HqZbb-EeGG7FhnhL0Fx8NgFNDf6xiIasRW6N3fa-g2JJNEE4PpBkll4oohLRILvUQMuIDtMMET7",
        "token_type": "Bearer",
        "expires_in": 3600,
        "scope": "playlist-read-private playlist-read-collaborative playlist-modify-private playlist-modify-public"
    }
    java.lang.NullPointerException
    	at com.spotify.oauth2.reports.ExtentLogger.info(ExtentLogger.java:39)
    	at com.spotify.oauth2.api.RestResource.printDetailsInExtentReport(RestResource.java:29)
    	at com.spotify.oauth2.api.RestResource.postAccount(RestResource.java:55)
    	at com.spotify.oauth2.api.TokenManager.renewToken(TokenManager.java:63)
    	at com.spotify.oauth2.api.TokenManager.getToken(TokenManager.java:28)
    	at com.spotify.oauth2.api.applicationApi.PlaylistApi.post(PlaylistApi.java:25)
    	at com.spotify.oauth2.tests.PlaylistTests_OC.ShouldBeAbleToCreateAPlaylist(PlaylistTests_OC.java:46)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
    	at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:598)
    	at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173)
    	at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
    	at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:824)
    	at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146)
    	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
    	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
    	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
    	at org.testng.TestRunner.privateRun(TestRunner.java:794)
    	at org.testng.TestRunner.run(TestRunner.java:596)
    	at org.testng.SuiteRunner.runTest(SuiteRunner.java:377)
    	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:371)
    	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:332)
    	at org.testng.SuiteRunner.run(SuiteRunner.java:276)
    	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
    	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
    	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1212)
    	at org.testng.TestNG.runSuitesLocally(TestNG.java:1134)
    	at org.testng.TestNG.runSuites(TestNG.java:1063)
    	at org.testng.TestNG.run(TestNG.java:1031)
    	at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
    	at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109)
    
    java.lang.RuntimeException: ABORT!! Failed to get Token
    
    	at com.spotify.oauth2.api.TokenManager.getToken(TokenManager.java:43)
    	at com.spotify.oauth2.api.applicationApi.PlaylistApi.post(PlaylistApi.java:25)
    	at com.spotify.oauth2.tests.PlaylistTests_OC.ShouldBeAbleToCreateAPlaylist(PlaylistTests_OC.java:46)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
    	at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:598)
    	at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173)
    	at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
    	at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:824)
    	at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146)
    	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
    	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
    	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
    	at org.testng.TestRunner.privateRun(TestRunner.java:794)
    	at org.testng.TestRunner.run(TestRunner.java:596)
    	at org.testng.SuiteRunner.runTest(SuiteRunner.java:377)
    	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:371)
    	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:332)
    	at org.testng.SuiteRunner.run(SuiteRunner.java:276)
    	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
    	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
    	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1212)
    	at org.testng.TestNG.runSuitesLocally(TestNG.java:1134)
    	at org.testng.TestNG.runSuites(TestNG.java:1063)
    	at org.testng.TestNG.run(TestNG.java:1031)
    	at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
    	at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109)
    
    opened by lucas-nguyen-17 1
  • refactor: change the way config listeners in testng

    refactor: change the way config listeners in testng

    Setting listeners in testng file has 2 disadvatages:

    • Error like https://github.com/rajatt95/MasterRestAssuredFramework/issues/1
    • It requires people run by testng.xml file --> kind of annoying when you need to change this file to run only one test

    This pull requests changes the setting from by file to by code:

    • people can run directly from IDE for each or many tests
    • if we create more testng.xml files or add more listeners, just one place to change.
    opened by lucas-nguyen-17 0
Owner
Rajat Verma
Test Automation Engineer | 5+ Years EXP. | C-DAC | India
Rajat Verma
A sample repo to help you emulate network control using CDP in Java-TestNG automation test on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to emulate network control using CDP in Java-TestNG automation test on LambdaTest Environment Setup Global Dependencies Install Maven Or Install M

null 12 Oct 23, 2022
A sample repo to help you set device mode using CDP in Java-TestNG automation test on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to set device mode using CDP in Java-TestNG automation test on LambdaTest Environment Setup Global Dependencies Install Maven Or Install Maven wit

null 11 Jul 13, 2022
A sample repo to help you capture JavaScript exception for automation test in Java-TestNG on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to capture JavaScript exception for automation test in Java-TestNG on LambdaTest Environment Setup Global Dependencies Install Maven Or Install Ma

null 11 Jul 13, 2022
A sample repo to help you use relative locators for automation test in Java-TestNG on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to use relative locators for automation test in Java-TestNG on LambdaTest Environment Setup Global Dependencies Install Maven Or Install Maven wit

null 11 Jul 13, 2022
A sample repo to help you use CDP console in Java-TestNG automation test on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to use CDP console in Java-TestNG automation test on LambdaTest Environment Setup Global Dependencies Install Maven Or Install Maven with Homebrew

null 11 Jul 13, 2022
A sample repo to help you set geolocation for automation test in Java-TestNG on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to set geolocation for automation test in Java-TestNG on LambdaTest Environment Setup Global Dependencies Install Maven Or Install Maven with Home

null 12 Jul 13, 2022
A sample repo to help you handle basic auth for automation test in Java-TestNG on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to handle basic auth for automation test in Java-TestNG on LambdaTest Environment Setup Global Dependencies Install Maven Or Install Maven with Ho

null 11 Jul 13, 2022
A sample repo to help you capture performance logs in Java-TestNG using CDP on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to capture performance logs in Java-TestNG using CDP on LambdaTest Environment Setup Global Dependencies Install Maven Or Install Maven with Homeb

null 12 Jul 13, 2022
A sample repo to help you intercept network with Java-TestNG on LambdaTest cloud. Run Selenium tests with TestNG on LambdaTest platform.

How to intercept network with Java-TestNG on LambdaTest cloud Environment Setup Global Dependencies Install Maven Or Install Maven with Homebrew (Easi

null 12 Oct 23, 2022
A sample repo to help you test in Java-TestNG-Appium for LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

Sample automation test in Java-TestNG-Appium for LambdaTest Environment Setup Global Dependencies Install Maven Or Install Maven with Homebrew (Easier

null 13 Jul 13, 2022