Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed Mar 13, 2020
2 parents 1f4c1cf + 65ecd07 commit 94fdc28
Show file tree
Hide file tree
Showing 28 changed files with 192 additions and 139 deletions.
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,13 @@ subprojects {
compile "org.objenesis:objenesis:${objenesisVersion}"
compile "org.slf4j:slf4j-api:${slf4jVersion}"
compile "xml-apis:xml-apis:${xmlApisVersion}"
compile "io.cucumber:cucumber-core:${cucumberVersion}"
compile ("io.cucumber:cucumber-core:${cucumberVersion}") {
exclude group: "org.apiguardian", module: 'apiguardian-api'
}
compile ("io.cucumber:cucumber-java:${cucumberVersion}") {
exclude group: "org.apiguardian", module: 'apiguardian-api'
}


compile("commons-logging:commons-logging:${commonsLoggingVersion}")
testCompile "junit:junit:${junitVersion}"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ gsonVersion = 2.8.4
typesafeConfigVersion = 1.3.1
freemarkerVersion = 2.3.29
wiremockCoreVersion = 1.58
cucumberVersion = 2.4.0
cucumberVersion = 5.4.2
commonsLoggingVersion = 1.2
xmlApisVersion = 1.4.01
cglibVersion = 3.3.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package net.serenitybdd.core.pages;

import cucumber.runtime.Env;
import net.serenitybdd.core.environment.ConfiguredEnvironment;
import net.serenitybdd.core.environment.EnvironmentSpecificConfiguration;
import net.thucydides.core.annotations.DefaultUrl;
import net.thucydides.core.annotations.NamedUrl;
import net.thucydides.core.annotations.NamedUrls;
import net.thucydides.core.configuration.SystemPropertiesConfiguration;
import net.thucydides.core.guice.Injectors;
import net.thucydides.core.util.EnvironmentVariables;
import net.thucydides.core.webdriver.Configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,14 @@ public void cancelPreviousTest() {
}
}

public void lastTestPassedAfterRetries(int remainingTries, List<String> failureMessages, TestFailureCause testfailureCause) {
public void lastTestPassedAfterRetries(int attemptNum, List<String> failureMessages, TestFailureCause testfailureCause) {
if (latestTestOutcome().isPresent()) {
latestTestOutcome().get().recordStep(
TestStep.forStepCalled("UNSTABLE TEST:\n" + failureHistoryFor(failureMessages))
.withResult(UNDEFINED));
// .withResult(TestResult.IGNORED));

latestTestOutcome().get().addTag(TestTag.withName("Retries: " + (remainingTries - 1)).andType("unstable test"));
latestTestOutcome().get().addTag(TestTag.withName("Retries: " + attemptNum).andType("unstable test"));
latestTestOutcome().get().setFlakyTestFailureCause(testfailureCause);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package net.serenitybdd.core.model
import cucumber.api.PendingException

import io.cucumber.java.PendingException
import net.serenitybdd.core.PendingStepException
import net.serenitybdd.core.exceptions.TestCompromisedException
import net.serenitybdd.core.model.sampleexceptions.MyFailureException
import net.thucydides.core.model.TestResult
import net.thucydides.core.model.failures.FailureAnalysis
import net.thucydides.core.steps.StepFailureException
import net.thucydides.core.util.MockEnvironmentVariables
Expand All @@ -13,8 +15,6 @@ import org.openqa.selenium.WebDriverException
import spock.lang.Specification
import spock.lang.Unroll

import static net.thucydides.core.model.TestResult.*

class WhenReportingExceptions extends Specification {

def failureAnalysisOf = new FailureAnalysis()
Expand All @@ -29,29 +29,29 @@ class WhenReportingExceptions extends Specification {

where:
exception | expectedResult
new WebdriverAssertionError(new NullPointerException()) | ERROR
new WebdriverAssertionError(new NoSuchElementException()) | ERROR
new StepFailureException("bother", new NoSuchElementException()) | ERROR
new AssertionError("test message") | FAILURE
new SoftAssertionError(["test message"]) | FAILURE
new WebdriverAssertionError(new NullPointerException()) | TestResult.ERROR
new WebdriverAssertionError(new NoSuchElementException()) | TestResult.ERROR
new StepFailureException("bother", new NoSuchElementException()) | TestResult.ERROR
new AssertionError("test message") | TestResult.FAILURE
new SoftAssertionError(["test message"]) | TestResult.FAILURE
new ArrayComparisonFailure("test message",
new AssertionError("wrapped exception"), 1) | FAILURE
new WebdriverAssertionError(new AssertionError("wrapped assertion error")) | FAILURE
new StepFailureException("bother", new AssertionError("test message")) | FAILURE
new RuntimeException("message") | ERROR
new NullPointerException() | ERROR
new WebDriverException() | ERROR
new PendingStepException("step is pending") | PENDING
new PendingException("step is pending") | PENDING
new TestCompromisedException("test is compromised") | COMPROMISED
new AssertionError("wrapped exception"), 1) | TestResult.FAILURE
new WebdriverAssertionError(new AssertionError("wrapped assertion error")) | TestResult.FAILURE
new StepFailureException("bother", new AssertionError("test message")) | TestResult.FAILURE
new RuntimeException("message") | TestResult.ERROR
new NullPointerException() | TestResult.ERROR
new WebDriverException() | TestResult.ERROR
new PendingStepException("step is pending") | TestResult.PENDING
new PendingException("step is pending") | TestResult.PENDING
new TestCompromisedException("test is compromised") | TestResult.COMPROMISED
}

def "non-assertion exceptions should be reported as Errors by default"() {
when:
def failureAnalysisOf = new FailureAnalysis()
def result = failureAnalysisOf.resultFor(new MyFailureException())
then:
result == ERROR
result == TestResult.ERROR
}

def "should be able to define what exceptions cause failures using serenity.fail.on"() {
Expand All @@ -63,7 +63,7 @@ class WhenReportingExceptions extends Specification {
def failureAnalysisOf = new FailureAnalysis(environmentVariables)
def result = failureAnalysisOf.resultFor(new MyFailureException())
then:
result == FAILURE
result == TestResult.FAILURE
}

def "should be able to override failures as errors using serenity.error.on"() {
Expand All @@ -75,7 +75,7 @@ class WhenReportingExceptions extends Specification {
def failureAnalysisOf = new FailureAnalysis(environmentVariables)
def result = failureAnalysisOf.resultFor(new AssertionError("oh crap"))
then:
result == ERROR
result == TestResult.ERROR
}

def "should be able to override errors as compromised using serenity.compromised.on"() {
Expand All @@ -87,7 +87,7 @@ class WhenReportingExceptions extends Specification {
def failureAnalysisOf = new FailureAnalysis(environmentVariables)
def result = failureAnalysisOf.resultFor(new AssertionError("oh crap"))
then:
result == COMPROMISED
result == TestResult.COMPROMISED
}

def "should be able to override errors as skipped using serenity.skip.on"() {
Expand All @@ -99,7 +99,7 @@ class WhenReportingExceptions extends Specification {
def failureAnalysisOf = new FailureAnalysis(environmentVariables)
def result = failureAnalysisOf.resultFor(new AssertionError("oh crap"))
then:
result == SKIPPED
result == TestResult.SKIPPED
}

def "should be able to override errors as failures"() {
Expand All @@ -112,7 +112,7 @@ class WhenReportingExceptions extends Specification {
def failureAnalysisOf = new FailureAnalysis(environmentVariables)
def result = failureAnalysisOf.resultFor(new NoSuchElementException())
then:
result == FAILURE
result == TestResult.FAILURE
}

def "should be able to override errors as pending"() {
Expand All @@ -124,7 +124,7 @@ class WhenReportingExceptions extends Specification {
def failureAnalysisOf = new FailureAnalysis(environmentVariables)
def result = failureAnalysisOf.resultFor(new MyFailureException())
then:
result == PENDING
result == TestResult.PENDING
}

def "should be able to override errors as failures even with nested errors"() {
Expand All @@ -137,7 +137,7 @@ class WhenReportingExceptions extends Specification {
def failureAnalysisOf = new FailureAnalysis(environmentVariables)
def result = failureAnalysisOf.resultFor(new StepFailureException("oh bother!",new NoSuchElementException()))
then:
result == FAILURE
result == TestResult.FAILURE
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -446,14 +446,15 @@ private void retryAtMost(int remainingTries,
RerunTest rerunTest) {
if (remainingTries <= 0) { return; }

logger.info(rerunTest.toString() + ": attempt " + (maxRetries() - remainingTries));
int attemptNum = maxRetries() - remainingTries + 1;
logger.info(rerunTest.toString() + ": attempt " + attemptNum);
StepEventBus.getEventBus().cancelPreviousTest();
rerunTest.perform();

if (failureDetectingStepListener.lastTestFailed()) {
retryAtMost(remainingTries - 1, rerunTest);
} else {
StepEventBus.getEventBus().lastTestPassedAfterRetries(remainingTries,
StepEventBus.getEventBus().lastTestPassedAfterRetries(attemptNum,
failureDetectingStepListener.getFailureMessages(),failureDetectingStepListener.getTestFailureCause());
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.thucydides.core.model.failures;

import cucumber.api.PendingException;
import io.cucumber.java.PendingException;
import net.serenitybdd.core.PendingStepException;
import net.serenitybdd.core.environment.ConfiguredEnvironment;
import net.serenitybdd.core.exceptions.CausesAssertionFailure;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.thucydides.core.model.failures;

import com.google.common.base.Splitter;
import cucumber.api.PendingException;
import io.cucumber.java.PendingException;
import net.serenitybdd.core.PendingStepException;
import net.serenitybdd.core.SkipStepException;
import net.serenitybdd.core.exceptions.CausesAssertionFailure;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.thucydides.core.reports;

import cucumber.api.formatter.AnsiEscapes;
import net.serenitybdd.core.CurrentOS;
import net.thucydides.core.ThucydidesSystemProperty;
import net.thucydides.core.util.EnvironmentVariables;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.thucydides.core.reports.html;

import gherkin.ast.Tag;

import io.cucumber.core.internal.gherkin.ast.Tag;
import net.thucydides.core.model.TestTag;

import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package net.thucydides.core.requirements.model.cucumber;

import gherkin.ast.Feature;
import gherkin.ast.ScenarioDefinition;


import io.cucumber.core.internal.gherkin.ast.Feature;
import io.cucumber.core.internal.gherkin.ast.ScenarioDefinition;

import java.util.List;

Expand Down
Loading

0 comments on commit 94fdc28

Please sign in to comment.