Skip to content

Commit 68c0705

Browse files
Web AssertJ tests
1 parent c34334b commit 68c0705

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/test/java/demo/customassert/ProductPageAssert.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
public class ProductPageAssert extends AbstractAssert<ProductPageAssert, ProductPageValidator> {
77

88
SoftAssertions assertions;
9-
protected ProductPageAssert(ProductPageValidator productPageAssert) {
10-
super(productPageAssert, ProductPageAssert.class);
9+
private ProductPageAssert(ProductPageValidator productPageValidator) {
10+
super(productPageValidator, ProductPageAssert.class);
1111
assertions=new SoftAssertions();
1212
}
1313

14-
public static ProductPageValidator getValidator(){
15-
return null;
14+
public static ProductPageAssert assertThat(ProductPageValidator productPageValidator){
15+
return new ProductPageAssert(productPageValidator);
1616
}
1717

1818
public ProductPageAssert productNameIs(String productName){
@@ -38,6 +38,4 @@ public ProductPageAssert matchesDefaultCartCount(){
3838
public void assertAll(){
3939
assertions.assertAll();
4040
}
41-
42-
4341
}

src/test/java/demo/customassert/ProductTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package demo.customassert;
22

3-
import org.testng.Assert;
43
import org.testng.annotations.Test;
54

65
public class ProductTest extends BaseTest{
@@ -9,8 +8,7 @@ public class ProductTest extends BaseTest{
98
public void verifyLoginPageSpec(){
109
ProductPage productPage=ProductPage.getProductPage();
1110
productPage.loadProductPage();
12-
ProductPageAssert productAssert=new ProductPageAssert(productPage.getValidator());
13-
productAssert
11+
ProductPageAssert.assertThat(productPage.getValidator())
1412
.productNameIs("iPhone")
1513
.productCodeIs("product 11")
1614
.productAvailabilityIs("In Stock")

0 commit comments

Comments
 (0)