diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index f998dd5..c66eeb4 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -9,6 +9,9 @@ on:
- master
- issue-*
+permissions:
+ contents: write
+
jobs:
build_and_test:
name: Build and Test
@@ -16,80 +19,22 @@ jobs:
steps:
- name: checkout Git repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
- name: Install Java and Maven
- uses: actions/setup-java@v2
+ uses: actions/setup-java@v4
with:
- java-version: '15'
+ java-version: '21'
distribution: 'adopt'
cache: maven
- - name: Build the Project
- run: mvn clean install -DskipTests
-
- - name: Test Execution
- run: mvn org.jacoco:jacoco-maven-plugin:prepare-agent install -Pcoverage-per-test
-
- - name: Upload target folder
- uses: actions/upload-artifact@v2
- with:
- name: target
- path: |
- ${{ github.workspace }}/target
- ${{ github.workspace }}/reports
- code_analysis:
- name: Code Analysis
- needs:
- - build_and_test
-
- runs-on: ubuntu-latest
-
- steps:
- - name: checkout Git repository
- uses: actions/checkout@v2
- with:
- fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
-
- - name: Install Java and Maven
- uses: actions/setup-java@v2
- with:
- java-version: '15'
- distribution: 'adopt'
- cache: maven
-
- - name: Cache SonarCloud packages
- uses: actions/cache@v2
- with:
- path: ~/.sonar/cache
- key: ${{ runner.os }}-sonar
- restore-keys: ${{ runner.os }}-sonar
-
- - name: Cache Maven packages
- uses: actions/cache@v2
- with:
- path: ~/.m2
- key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
- restore-keys: ${{ runner.os }}-m2
-
- - name: Download target folder
- uses: actions/download-artifact@v2
- with:
- name: target
+ - name: Build the Project and run tests
+ run: mvn clean install
- - name: Sonar Code Analysis
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
- SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- SONAR_KEY: ${{ secrets.SONAR_KEY }}
- run: |
- mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
- -Dsonar.projectKey=$SONAR_KEY
- name: Test Report
- uses: dorny/test-reporter@v1
+ uses: dorny/test-reporter@v2
if: success() || failure()
with:
name: Test Results
path: ${{ github.workspace }}/target/surefire-reports/TEST-TestSuite.xml
- reporter: java-junit
- java-version: 11
+ reporter: java-junit
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index eb1b62e..0ec06ee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,10 +1,40 @@
-/target/
-/test-output/
-/settings/
-/reports/
-/logs/
-/.settings/
-/.classpath
-/.project
-/.idea/
-/*.iml/
\ No newline at end of file
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+test-output/
+
+### IntelliJ IDEA ###
+.idea/
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/README.md b/README.md
index fe33337..9841ae5 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,6 @@
-
[](https://opensource.org/licenses/Apache-2.0)
[](https://github.com/mfaisalkhatri/OkHttpRestAssuredExamples/actions/workflows/maven.yml)
-[](https://sonarcloud.io/summary/new_code?id=mfaisalkhatri_OkHttpRestAssuredExamples)
-[](https://sonarcloud.io/summary/new_code?id=mfaisalkhatri_OkHttpRestAssuredExamples)
-[](https://sonarcloud.io/summary/new_code?id=mfaisalkhatri_OkHttpRestAssuredExamples)
-[](https://sonarcloud.io/summary/new_code?id=mfaisalkhatri_OkHttpRestAssuredExamples)
-
## Don't forget to give a :star: to make the project popular.
@@ -17,10 +11,9 @@ I heard a lot about Rest-Assured and OkHttp and how it made the QA's life easier
Hence, I started learning about these frameworks and have documented all my learnings in this repository.
-Checkout my blog [API Testing using RestAssured and OkHttp][blog] where I talk about these frameworks in details
+Checkout my blog [API Testing using RestAssured and OkHttp](https://mfaisalkhatri.github.io/2020/05/29/restassuredokhttp/) where I talk about these frameworks in details
and which one to choose for testing your APIs.
-To get a better understanding on API Testing, check [What is API Testing?][blog_apitesting]
## Details about this Project:
@@ -31,18 +24,31 @@ To get a better understanding on API Testing, check [What is API Testing?][blog_
- Lombok has been used to generate Getter and Setters automatically for post body requests.
- Rest APIs on https://reqres.in/ have been used for testing.
+## :writing_hand: Blog Links
+
+ - [What is API Testing?](https://mfaisalkhatri.github.io/2020/08/08/apitesting/)
+ - [End to End API Testing using Rest-Assured](https://medium.com/@iamfaisalkhatri/end-to-end-api-testing-using-rest-assured-a58c4ea80255)
+
+## :movie_camera: Tutorial Video
+
+[](https://www.youtube.com/watch?v=xLKpdQE0oKY&t=1s)
+[](https://www.youtube.com/live/AFQSolEeu74?si=8WROMbunjUuzqqQj&t=1)
+
+
## :question: Need Assistance?
-- Discuss your queries by writing to me at [mohammadfaisalkhatri@gmail.com][mail] or you can ping me on the following social media sites:
-- Twitter: [mfaisal_khatri][twitter]
-- LinkedIn: [Mohammad Faisal Khatri][linkedin]
-- Contact me for 1:1 trainings related to Test Automation.
+- Discuss your queries by writing to me @ `mohammadfaisalkhatri@gmail.com`
+ OR ping me on any of the social media sites using the below link:
+ - [Linktree](https://linktr.ee/faisalkhatri)
+
+## :computer: Paid Trainings
+
+Contact me for Paid trainings related to Test Automation and Software Testing,
+mail me @`mohammadfaisalkhatri@gmail.com` or ping me on [LinkedIn](https://www.linkedin.com/in/faisalkhatri/)
-## :thought_balloon: Checkout the blogs related to Testing on my [website][]
+## :thought_balloon: Checkout the blogs related to Software Testing and Test Automation on the following links:
+- [Medium Blogs](https://medium.com/@iamfaisalkhatri)
+- [LambdaTest Blogs](https://www.lambdatest.com/blog/author/mfaisalkhatri/)
+- [My Website](https://mfaisalkhatri.github.io)
-[mail]: mohammadfaisalkhatri@gmail.com
-[linkedin]: https://www.linkedin.com/in/faisalkhatri/
-[twitter]: https://twitter.com/mfaisal_khatri
-[website]: https://mfaisalkhatri.github.io
-[blog]: https://mfaisalkhatri.github.io/2020/05/29/restassuredokhttp/
-[blog_apitesting]: https://mfaisalkhatri.github.io/2020/08/08/apitesting/
\ No newline at end of file
+## Subscribe to my [YouTube Channel](https://www.youtube.com/@faisalkhatriqa)
\ No newline at end of file
diff --git a/okhttppoc.iml b/okhttppoc.iml
deleted file mode 100644
index 2c394a8..0000000
--- a/okhttppoc.iml
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 43fbe06..bcddc62 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,7 +1,7 @@
-
4.0.0
@@ -13,91 +13,83 @@
https://mfaisalkhatri.github.io
- UTF-8
- 3.8.1
- 3.0.0-M5
- 15
+ 7.11.0
+ 4.9.3
+ 5.5.5
+ 1.3
+ 2.25.1
+ 2.25.1
+ 1.1.1
+ 1.18.38
+ 2.19.2
+ 20250517
+ 1.0.2
+ 3.14.0
+ 3.5.3
+ -Dfile.encoding=UTF-8 -Xdebug -Xnoagent
+ 3.8.1
+ 17
UTF-8
testng.xml
- -Dfile.encoding=UTF-8 -Xdebug -Xnoagent
- https://sonarcloud.io
- ${project.basedir}/target/reports/jacoco.exec
- mfaisalkhatri
- ${project.basedir}/reports/jacoco.exec
- ${project.basedir}/target/site/jacoco/jacoco.xml
-
- 15
- 0.8.7
- 5.14.0.18788
- target/dependency/*.jar
- 3.2.0
+ UTF-8
-
-
org.testng
testng
- 7.5
+ ${testng.version}
-
com.squareup.okhttp3
okhttp
- 4.9.3
+ ${okhttp3.version}
+ provided
io.rest-assured
rest-assured
- 4.4.0
+ ${restassured.version}
-
org.hamcrest
hamcrest-all
- 1.3
+ ${hamcrest.version}
-
org.apache.logging.log4j
log4j-core
- 2.17.1
+ ${log4j.core.version}
-
org.apache.logging.log4j
log4j-api
- 2.17.1
+ ${log4j.api.version}
-
com.googlecode.json-simple
json-simple
- 1.1.1
+ ${jsonsimple.version}
-
org.projectlombok
lombok
- 1.18.22
+ ${lombok.version}
provided
-
com.fasterxml.jackson.core
jackson-databind
- 2.13.4.1
+ ${jackson.databind.version}
-
org.json
json
- 20211205
+ ${orgjson.version}
com.github.javafaker
javafaker
- 1.0.2
+ ${javafaker.version}
@@ -154,74 +146,6 @@
-
- org.sonarsource.scanner.maven
- sonar-maven-plugin
- 3.9.1.2184
-
-
- org.jacoco
- jacoco-maven-plugin
- ${jacoco.version}
-
-
- prepare-agent
-
- prepare-agent
-
-
- ${sonar.report}
- surefireArgLine
-
-
-
- report
- test
-
- report
-
-
- ${sonar.report}
- ${project.reporting.outputDirectory}/jacoco
-
-
-
-
-
-
- coverage-per-test
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- ${surefire-version}
-
-
-
- test
-
-
-
-
-
- ${suite-xml}
-
- ${argLine} ${surefireArgLine}
-
-
-
-
-
-
- org.sonarsource.java
- sonar-jacoco-listeners
- ${sonar.version}
- test
-
-
-
-
\ No newline at end of file
diff --git a/src/main/java/com/faisalkhatri/okhttppoc/AuthenticationPojo.java b/src/main/java/com/faisalkhatri/okhttppoc/AuthenticationPojo.java
index 37dc857..0448082 100644
--- a/src/main/java/com/faisalkhatri/okhttppoc/AuthenticationPojo.java
+++ b/src/main/java/com/faisalkhatri/okhttppoc/AuthenticationPojo.java
@@ -21,7 +21,6 @@
/**
* @author Faisal Khatri
* @since Aug 2, 2020
- *
*/
@Data
public class AuthenticationPojo {
@@ -30,9 +29,10 @@ public class AuthenticationPojo {
private String password;
/**
- *@author Faisal Khatri
- *@param email
- *@param password
+ * @param email
+ * @param password
+ *
+ * @author Faisal Khatri
*/
public AuthenticationPojo (String email, String password) {
this.email = email;
diff --git a/src/main/java/com/faisalkhatri/okhttppoc/PostData.java b/src/main/java/com/faisalkhatri/okhttppoc/PostData.java
index b66a20d..8e669fa 100644
--- a/src/main/java/com/faisalkhatri/okhttppoc/PostData.java
+++ b/src/main/java/com/faisalkhatri/okhttppoc/PostData.java
@@ -21,25 +21,23 @@
/**
* @since Mar 7, 2020
- *
*/
@Getter
@Setter
public class PostData {
- private final String name;
- private final String job;
+ private final String job;
+ private final String name;
- /**
- *
- * @author Faisal Khatri
- * @param name
- * @param job
- */
- public PostData (final String name, final String job) {
- this.name = name;
- this.job = job;
-
- }
+ /**
+ * @param name
+ * @param job
+ *
+ * @author Faisal Khatri
+ */
+ public PostData (final String name, final String job) {
+ this.name = name;
+ this.job = job;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/faisalkhatri/okhttppoc/TestListener.java b/src/main/java/com/faisalkhatri/okhttppoc/TestListener.java
index a2a34f4..99af70e 100644
--- a/src/main/java/com/faisalkhatri/okhttppoc/TestListener.java
+++ b/src/main/java/com/faisalkhatri/okhttppoc/TestListener.java
@@ -28,15 +28,18 @@
* @since Mar 8, 2020
*/
public class TestListener implements ITestListener {
-
Logger log = LogManager.getLogger (TestListener.class);
- private void logMessage (final String message) {
- this.log.info ("\n");
- this.log.info (repeat ("=", 75));
- this.log.info (message);
- this.log.info (repeat ("=", 75));
- this.log.info ("\n");
+ @Override
+ public void onFinish (final ITestContext context) {
+ logMessage ("Test Execution Completed Successfully for all tests!!" + context.getSuite ()
+ .getAllMethods ());
+
+ }
+
+ @Override
+ public void onTestFailure (final ITestResult result) {
+ logMessage ("Test Failed!!!!" + result.getName ());
}
@Override
@@ -50,16 +53,11 @@ public void onTestSuccess (final ITestResult result) {
}
- @Override
- public void onTestFailure (final ITestResult result) {
- logMessage ("Test Failed!!!!" + result.getName ());
- }
-
- @Override
- public void onFinish (final ITestContext context) {
- logMessage ("Test Execution Completed Successfully for all tests!!" + context.getSuite ()
- .getAllMethods ());
-
+ private void logMessage (final String message) {
+ this.log.info ("\n");
+ this.log.info (repeat ("=", 75));
+ this.log.info (message);
+ this.log.info (repeat ("=", 75));
+ this.log.info ("\n");
}
-
}
\ No newline at end of file
diff --git a/src/test/java/com/faisalkhatri/okhttppoc/SetupConfig.java b/src/test/java/com/faisalkhatri/okhttppoc/SetupConfig.java
index 3a01348..81c0c67 100644
--- a/src/test/java/com/faisalkhatri/okhttppoc/SetupConfig.java
+++ b/src/test/java/com/faisalkhatri/okhttppoc/SetupConfig.java
@@ -16,6 +16,8 @@
package com.faisalkhatri.okhttppoc;
+import static org.hamcrest.Matchers.lessThan;
+
import io.restassured.RestAssured;
import io.restassured.builder.RequestSpecBuilder;
import io.restassured.builder.ResponseSpecBuilder;
@@ -25,24 +27,19 @@
import io.restassured.specification.ResponseSpecification;
import org.testng.annotations.BeforeClass;
-import static org.hamcrest.Matchers.lessThan;
-
public class SetupConfig {
@BeforeClass
- public void setup() {
+ public void setup () {
RestAssured.baseURI = "https://reqres.in/";
-
- RequestSpecification request = new RequestSpecBuilder()
- .addHeader("Content-Type", "application/json")
- .addHeader("Accept", "application/json")
- .addFilter(new RequestLoggingFilter())
- .addFilter(new ResponseLoggingFilter())
- .build();
-
- ResponseSpecification response = new ResponseSpecBuilder()
- .expectResponseTime(lessThan(5000L))
- .build();
+ RequestSpecification request = new RequestSpecBuilder ().addHeader ("Content-Type", "application/json")
+ .addHeader ("Accept", "application/json")
+ .addFilter (new RequestLoggingFilter ())
+ .addFilter (new ResponseLoggingFilter ())
+ .build ();
+
+ ResponseSpecification response = new ResponseSpecBuilder ().expectResponseTime (lessThan (5000L))
+ .build ();
RestAssured.requestSpecification = request;
RestAssured.responseSpecification = response;
diff --git a/src/test/java/com/faisalkhatri/okhttppoc/TestAuthentication.java b/src/test/java/com/faisalkhatri/okhttppoc/TestAuthentication.java
index cbea9ec..5d0141f 100644
--- a/src/test/java/com/faisalkhatri/okhttppoc/TestAuthentication.java
+++ b/src/test/java/com/faisalkhatri/okhttppoc/TestAuthentication.java
@@ -39,54 +39,18 @@ public class TestAuthentication {
private static final String URL = "https://reqres.in";
/**
- * @author Faisal Khatri
- * @since Aug 2, 2020
- * @return test data
- */
- @DataProvider
- public Iterator