From a2b3ce522aa414aecc334e80b007ce68425d50b1 Mon Sep 17 00:00:00 2001 From: AlexanderKotlyar Date: Fri, 10 Nov 2017 14:24:10 +0300 Subject: [PATCH] Refs #1. added allure reports, replaced soft assertion rule with manual soft assertion close --- src/test/java/com/qiwi/bonus/StepsLogger.java | 8 ++--- .../java/com/qiwi/bonus/pages/PageSource.java | 2 +- .../tests/api/BonusSiteMapLinksTest.java | 33 +++++-------------- 3 files changed, 13 insertions(+), 30 deletions(-) diff --git a/src/test/java/com/qiwi/bonus/StepsLogger.java b/src/test/java/com/qiwi/bonus/StepsLogger.java index 0354aa6..610dfb7 100644 --- a/src/test/java/com/qiwi/bonus/StepsLogger.java +++ b/src/test/java/com/qiwi/bonus/StepsLogger.java @@ -10,7 +10,7 @@ public class StepsLogger { @Step - public void assertion(String assertion, Runnable r) { + protected void assertion(String assertion, Runnable r) { try { r.run(); info("Assertion PASSED: " + assertion); @@ -21,7 +21,7 @@ public void assertion(String assertion, Runnable r) { } @Step - public void act(String act, Runnable r) { + protected void act(String act, Runnable r) { try { r.run(); info("Act PASSED: " + act); @@ -33,7 +33,7 @@ public void act(String act, Runnable r) { @Step - public void arrange(String arrange, Runnable r) { + protected void arrange(String arrange, Runnable r) { try { r.run(); info("Arrange PASSED: " + arrange); @@ -45,7 +45,7 @@ public void arrange(String arrange, Runnable r) { private static final Logger LOGGER = Logger.getLogger(StepsLogger.class.getName()); - public void info(String logMessage) { + private void info(String logMessage) { getLoggerInstance().info(logMessage); } diff --git a/src/test/java/com/qiwi/bonus/pages/PageSource.java b/src/test/java/com/qiwi/bonus/pages/PageSource.java index 75310ce..926caca 100644 --- a/src/test/java/com/qiwi/bonus/pages/PageSource.java +++ b/src/test/java/com/qiwi/bonus/pages/PageSource.java @@ -9,7 +9,7 @@ import static io.restassured.RestAssured.given; /** - * Created by power on 10.11.2017. 2:18 + * Created by alexander.kotlyar on 10.11.2017. 2:18 */ public class PageSource { public List getLinksFromPageSourceStartingWith(String pageSource, String schema) { diff --git a/src/test/java/com/qiwi/bonus/tests/api/BonusSiteMapLinksTest.java b/src/test/java/com/qiwi/bonus/tests/api/BonusSiteMapLinksTest.java index a3836f5..f0eda29 100644 --- a/src/test/java/com/qiwi/bonus/tests/api/BonusSiteMapLinksTest.java +++ b/src/test/java/com/qiwi/bonus/tests/api/BonusSiteMapLinksTest.java @@ -3,17 +3,11 @@ import com.qiwi.bonus.StepsLogger; import com.qiwi.bonus.pages.PageSource; import io.qameta.allure.Issue; -import io.qameta.allure.restassured.AllureRestAssured; -import io.restassured.RestAssured; import io.restassured.response.Response; -import org.assertj.core.api.JUnitSoftAssertions; -import org.jsoup.Jsoup; -import org.jsoup.select.Elements; +import org.assertj.core.api.SoftAssertions; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import java.util.ArrayList; import java.util.List; import static io.restassured.RestAssured.given; @@ -27,13 +21,10 @@ public class BonusSiteMapLinksTest extends StepsLogger { private static String BONUS_SITEMAP_PAGE_SOURCE; private List allBonusSiteMapLinks; private PageSource pageSource = new PageSource(); - - @Rule - public final JUnitSoftAssertions softly = new JUnitSoftAssertions(); + private SoftAssertions softAssertions = new SoftAssertions(); @Before public void checkBonusSiteMapIsAvailable() throws Exception { - RestAssured.filters(new AllureRestAssured()); given() .when() .get(HTTPS_BONUS_QIWI_COM_SITEMAP) @@ -56,25 +47,17 @@ public void testAvailabilityOfAllBonusSiteMapLinks() throws Exception { act("Collect all links from sitemap", () -> allBonusSiteMapLinks = pageSource.getLinksFromPageSourceStartingWith(BONUS_SITEMAP_PAGE_SOURCE, BONUS_LINK_SCHEMA)); - assertion("Check each link availability (200 response status code)", () -> - //allBonusSiteMapLinks.forEach(this::assertStatusCode)); //12 minutes - allBonusSiteMapLinks.parallelStream().forEach(this::assertStatusCode)); //1 minute + assertion("Check each link availability (200 response status code)", () -> { + allBonusSiteMapLinks.parallelStream().forEach(this::assertStatusCode); + softAssertions.assertAll(); + }); } - /* - - These links had status 500 between 23:22:22 and 23:23:15 on Nov.9.2017: - - [link: 'https://bonus.qiwi.com/offers/sovest'] - [link: 'https://bonus.qiwi.com/offers/ssylka-dlya-mfo-na-qiwi-com'] - - */ - private void assertStatusCode(String link) { Response response = given() .when() .head(link); - softly.assertThat(response.statusCode()).as("link: '" + link + "'").isEqualTo(200); + softAssertions.assertThat(response.statusCode()).as("link: '" + link + "'").isEqualTo(200); } -} +} \ No newline at end of file