Skip to content

Fixed reqrest tests by adding api key, updated versions of dependencies and plugins, formatting changes done. #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ jobs:
run: mvn clean install -DskipTests

- name: Run tests
run: mvn clean test
env:
API_KEY: ${{ secrets.REQRES_API_KEY }}
run: mvn clean test -Dapi-key=$API_KEY

- name: Stop restful booker service
run: docker compose -f ./docker-compose-restfulbooker.yml down --remove-orphans
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ You will get the answers to the following questions and its respective working c
## :writing_hand: Blog Links
- [What is API Testing?](https://mfaisalkhatri.github.io/2020/08/08/apitesting/)
- [How to perform End to End API Testing using Playwright with Java and TestNG](https://medium.com/@iamfaisalkhatri/how-to-perform-end-to-end-api-testing-using-playwright-with-java-and-testng-26b318927115)
- [Playwright Java API Testing | How to test POST requests?](https://medium.com/@iamfaisalkhatri/playwright-java-api-testing-how-to-test-post-requests-4c9102d3ab03)
- [Playwright Java API Testing | How to test GET requests?](https://medium.com/@iamfaisalkhatri/playwright-java-api-testing-how-to-test-get-requests-c036b984cc6d)
- [Playwright Java API Testing | How to test PUT requests?](https://medium.com/@iamfaisalkhatri/playwright-java-api-testing-how-to-test-put-requests-d6b1d054d64b)
- [Playwright Java API Testing | How to test PATCH requests?](https://medium.com/@iamfaisalkhatri/playwright-java-api-testing-how-to-test-patch-requests-f6b0867d91e7)
- [Playwright Java API Testing | How to test DELETE requests?](https://medium.com/@iamfaisalkhatri/playwright-java-api-testing-how-to-test-delete-requests-2ff77feb0383)
- [How to test POST API requests with Playwright Java](https://medium.com/@iamfaisalkhatri/playwright-java-api-testing-how-to-test-post-requests-4c9102d3ab03)
- [How to test GET API requests with Playwright Java](https://medium.com/@iamfaisalkhatri/playwright-java-api-testing-how-to-test-get-requests-c036b984cc6d)
- [How to test PUT API requests with Playwright Java](https://medium.com/@iamfaisalkhatri/playwright-java-api-testing-how-to-test-put-requests-d6b1d054d64b)
- [How to test PATCH API requests with Playwright Java](https://medium.com/@iamfaisalkhatri/playwright-java-api-testing-how-to-test-patch-requests-f6b0867d91e7)
- [How to test DELETE API requests with Playwright Java](https://medium.com/@iamfaisalkhatri/playwright-java-api-testing-how-to-test-delete-requests-2ff77feb0383)
- [How to Create a Custom Logger for Logging Response Details with Playwright Java](https://medium.com/@iamfaisalkhatri/playwright-java-api-testing-creating-custom-logger-for-logging-response-details-771e961d9faa)

## :question: Need Assistance?

Expand Down
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<playwright-version>1.50.0</playwright-version>
<playwright-version>1.52.0</playwright-version>
<testng-version>7.11.0</testng-version>
<hamcrest-all-version>1.3</hamcrest-all-version>
<json-simple-version>1.1.1</json-simple-version>
<lombok-version>1.18.36</lombok-version>
<datafaker-version>2.4.2</datafaker-version>
<gson-version>2.12.1</gson-version>
<org-json-verion>20250107</org-json-verion>
<jackson-databind-version>2.18.3</jackson-databind-version>
<lombok-version>1.18.38</lombok-version>
<datafaker-version>2.4.3</datafaker-version>
<gson-version>2.13.1</gson-version>
<org-json-verion>20250517</org-json-verion>
<jackson-databind-version>2.19.0</jackson-databind-version>
<log4j-core-version>2.24.1</log4j-core-version>
<log4j-api-version>2.24.1</log4j-api-version>
<commons-lang3-version>3.17.0</commons-lang3-version>
<maven-compiler-plugin-version>3.14.0</maven-compiler-plugin-version>
<maven-surefire-plugin-version>3.5.2</maven-surefire-plugin-version>
<maven-surefire-plugin-version>3.5.3</maven-surefire-plugin-version>
<java-release-version>17</java-release-version>
<maven-enforcer-version>3.5.2</maven-enforcer-version>
<suite-xml>test-suite/testng.xml</suite-xml>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package io.github.mfaisalkhatri.api.reqres.tests;

import java.util.HashMap;
import java.util.Map;

import io.github.mfaisalkhatri.api.manager.RequestManager;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;

import java.util.HashMap;
import java.util.Map;

/**
* @author Faisal Khatri
* @since 2/28/2023
Expand All @@ -15,13 +15,16 @@ public class BaseTest {

protected RequestManager manager;


@BeforeClass
public void setup() {
String apiKey = System.getProperty ("api-key");
this.manager = new RequestManager();
this.manager.createPlaywright();
final String baseUrl = "https://reqres.in";
final Map<String, String> headers = new HashMap<>();
headers.put("content-type", "application/json");
headers.put ("x-api-key", apiKey);
this.manager.setApiRequestContext(baseUrl, headers);
}

Expand Down
2 changes: 1 addition & 1 deletion test-suite/testng-reqres.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
</class>
</classes>
</test>
</suite> <!-- Suite -->
</suite>
2 changes: 1 addition & 1 deletion test-suite/testng-restfulecommerce-deleteorders.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
</class>
</classes>
</test>
</suite>
</suite>
2 changes: 1 addition & 1 deletion test-suite/testng-restfulecommerce-partialupdateorder.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
</class>
</classes>
</test>
</suite>
</suite>
2 changes: 1 addition & 1 deletion test-suite/testng-restfulecommerce-postandgetorder.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
</class>
</classes>
</test>
</suite>
</suite>
2 changes: 1 addition & 1 deletion test-suite/testng-restfulecommerce-updateorder.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
</class>
</classes>
</test>
</suite>
</suite>