Skip to content

Commit

Permalink
Refs #1. added allure reports, replaced soft assertion rule with manu…
Browse files Browse the repository at this point in the history
…al soft assertion close
  • Loading branch information
AlexanderKotlyar committed Nov 10, 2017
1 parent 9e3e65c commit a2b3ce5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 30 deletions.
8 changes: 4 additions & 4 deletions src/test/java/com/qiwi/bonus/StepsLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/qiwi/bonus/pages/PageSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> getLinksFromPageSourceStartingWith(String pageSource, String schema) {
Expand Down
33 changes: 8 additions & 25 deletions src/test/java/com/qiwi/bonus/tests/api/BonusSiteMapLinksTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,13 +21,10 @@ public class BonusSiteMapLinksTest extends StepsLogger {
private static String BONUS_SITEMAP_PAGE_SOURCE;
private List<String> 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)
Expand All @@ -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);
}
}
}

0 comments on commit a2b3ce5

Please sign in to comment.