Skip to content

Commit 1caa00d

Browse files
committed
updated sad path scenario assertions and corrected spelling mistake in message text recevied in response
1 parent fb40851 commit 1caa00d

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

src/test/java/io/github/mfaisalkhatri/api/restfulecommerce/SadPathTests.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void testShouldNotCreateOrder_WhenOrderListIsNotArray() {
4444
}
4545

4646
@Test
47-
public void testShouldNotFetchOrderWhenNoOrderExists() {
47+
public void testShouldNotFetchOrder_WhenNoOrderExists() {
4848

4949
final APIResponse response = this.request.get("/getAllOrders");
5050

@@ -54,11 +54,11 @@ public void testShouldNotFetchOrderWhenNoOrderExists() {
5454

5555
final JSONObject responseObject = new JSONObject(response.text());
5656
assertEquals(response.status(), 404);
57-
assertEquals(responseObject.get("message"), "No order found!!");
57+
assertEquals(responseObject.get("message"), "No Order found!!");
5858
}
5959

6060
@Test
61-
public void testShouldNotFetchOrderWhenNoOrderExistsForOrderId() {
61+
public void testShouldNotFetchOrder_WhenNoOrderExistsForOrderId() {
6262

6363
final int orderId = 90;
6464
final APIResponse response = this.request.get("/getOrder", RequestOptions.create().setQueryParam("id", orderId));
@@ -69,11 +69,11 @@ public void testShouldNotFetchOrderWhenNoOrderExistsForOrderId() {
6969
final JSONObject responseObject = new JSONObject(response.text());
7070

7171
assertEquals(response.status(), 404);
72-
assertEquals(responseObject.get("message"), "No order found with the given parameters!");
72+
assertEquals(responseObject.get("message"), "No Order found with the given parameters!");
7373
}
7474

7575
@Test
76-
public void testShouldNotFetchOrderWhenNoOrderExistsForUserId() {
76+
public void testShouldNotFetchOrder_WhenNoOrderExistsForUserId() {
7777
final String userId = "20";
7878

7979
final APIResponse response = this.request.get("/getOrder", RequestOptions.create().setQueryParam("user_id", userId));
@@ -84,12 +84,12 @@ public void testShouldNotFetchOrderWhenNoOrderExistsForUserId() {
8484
final JSONObject responseObject = new JSONObject(response.text());
8585

8686
assertEquals(response.status(), 404);
87-
assertEquals(responseObject.get("message"), "No order found with the given parameters!");
87+
assertEquals(responseObject.get("message"), "No Order found with the given parameters!");
8888

8989
}
9090

9191
@Test
92-
public void testShouldNotFetchOrderWhenNoOrderExistsForProductId() {
92+
public void testShouldNotFetchOrder_WhenNoOrderExistsForProductId() {
9393
final String productId = "987";
9494

9595
final APIResponse response = this.request.get("/getOrder", RequestOptions.create().setQueryParam("product_id", productId));
@@ -100,11 +100,11 @@ public void testShouldNotFetchOrderWhenNoOrderExistsForProductId() {
100100
final JSONObject responseObject = new JSONObject(response.text());
101101

102102
assertEquals(response.status(), 404);
103-
assertEquals(responseObject.get("message"), "No order found with the given parameters!");
103+
assertEquals(responseObject.get("message"), "No Order found with the given parameters!");
104104
}
105105

106106
@Test
107-
public void testShouldNotGenerateTokenForInvalidCredentials() {
107+
public void testShouldNotGenerateToken_WhenInvalidCredentialsAreGiven() {
108108

109109

110110
}

test-suite/testng-restfulecommerce.xml

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
33
<suite name="Restful ECommerce Test Suite">
4-
<test name="Testing Each API of ECommerce App separately">
4+
<test name="Testing Sad Path Scenarios of Restful E-Commerce APIs">
5+
<classes>
6+
<class name="io.github.mfaisalkhatri.api.restfulecommerce.SadPathTests">
7+
<methods>
8+
<include name="testShouldNotCreateOrder_WhenProductIdFieldIsMissing"/>
9+
<include name="testShouldNotCreateOrder_WhenOrderListIsNotArray"/>
10+
<include name="testShouldNotFetchOrder_WhenNoOrderExists"/>
11+
<include name="testShouldNotFetchOrder_WhenNoOrderExistsForOrderId"/>
12+
<include name="testShouldNotFetchOrder_WhenNoOrderExistsForUserId"/>
13+
<include name="testShouldNotFetchOrder_WhenNoOrderExistsForProductId"/>
14+
</methods>
15+
</class>
16+
</classes>
17+
</test>
18+
<test name="Testing Happy Path Scenarios of Restful E-Commerce APIs">
519
<classes>
620
<class name="io.github.mfaisalkhatri.api.restfulecommerce.HappyPathTests">
721
<methods>

0 commit comments

Comments
 (0)