1

I am developing some automated tests with Java 11.0.11 over Serenity+Cucumber+Gherkin in ScreenPlay pattern

have already done over a dozen stepsDefinition currently working without error but this one:

//SomeStepDefinitions.java:
String bar = "my String";

105:       theActorInTheSpotlight().should(
                seeThat(
                        theActorInTheSpotlight -> XPATH_TARGET1.resolveFor(theActorInTheSpotlight).getText()
                        , equalTo(bar)
                )
        );

throws arbitriarly

TEST FAILED

17:04:45.023 [Test worker] DEBUG  - RELATED ISSUES: 
17:04:45.087 [Test worker] ERROR  -     Test failed at step: Then do something step definitions$$ lambda$796/0x00000001006ce840 should be Predicates.equalTo(my String)
17:04:45.087 [Test worker] ERROR  -     predicate failed

predicate failed
java.lang.AssertionError: predicate failed
    at net.serenitybdd.screenplay.ErrorTally.throwSummaryExceptionFrom(ErrorTally.java:38)
    at net.serenitybdd.screenplay.ErrorTally.reportAnyErrors(ErrorTally.java:32)
    at net.serenitybdd.screenplay.Actor.should(Actor.java:322)
    at stepdefinitions.Folder1.Folder2.SomeStepDefinitions.Foo(SomeStepDefinitions.java:105)

any thoughs?

LCCEOR
  • 11
  • 5

2 Answers2

0

To anyone with this problem, already bypassed the problem with:

        theActorInTheSpotlight().attemptsTo(
                Ensure.that(FOO.value().answeredBy(theActorInTheSpotlight())).isEqualTo(bar)
        );

class FOO extends WebDriverQuestion implements Question<String> {
    @Override
    public String answeredBy(Actor actor) {
            return Text.of(XPATH_TARGET1).viewedBy(actor).asString();
    }
    public static FOO value(){
        return new FOO();
    }
}

I still want to know why initial code failed randomly.

LCCEOR
  • 11
  • 5
0

I don't know in this case why should(seeThat()) failed.

I had a similar exception when i passed a Question of Object to should(seeThat()).

My object had an overided equals method, and in that it was a line that could throw a null pointer exception. I resolved my problem by managing that null case.