JBehave
  1. JBehave
  2. JBEHAVE-859

uuidWrappedFailure is null when failure occurs

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 4.x
    • Fix Version/s: 4.0
    • Component/s: Core
    • Labels:
      None
    • Environment:
      Project based on ETSY tutorial
    • Number of attachments :
      1

      Description

      Hello !

      I'm new to JBehave, I've run my project with version 3.7.3 until now without many problems.

      I just tried to use the 4.0-beta-2 version to have steps timings, looks to work well, but I have an issue in WebDriverScreenshotOnFailure.afterScenarioFailure() :

      The UUIDExceptionWrapper uuidWrappedFailure is NULL.

      I didn't change many things in my configuration from 3.7.3 to 4.x

      I do not have all the skills needed to catch why that value is null, maybe something wrong in the framework, or a misconfiguration from my part ?

      Here is the trace :

      org.jbehave.web.selenium.WebDriverScreenshotOnFailure.afterScenarioFailure(org.jbehave.core.failures.UUIDExceptionWrapper) (ECHEC)
      (org.jbehave.core.failures.BeforeOrAfterFailed: Method afterScenarioFailure (annotated with @AfterScenario in class org.jbehave.web.selenium.WebDriverScreenshotOnFailure) failed: java.lang.NullPointerException)

      org.jbehave.core.failures.BeforeOrAfterFailed: Method afterScenarioFailure (annotated with @AfterScenario in class org.jbehave.web.selenium.WebDriverScreenshotOnFailure) failed: java.lang.NullPointerException
      at org.jbehave.core.steps.StepCreator$BeforeOrAfterStep.perform(StepCreator.java:462)
      at org.jbehave.core.steps.StepCreator$FailureStep.doNotPerform(StepCreator.java:519)
      at org.jbehave.core.embedder.PerformableTree$SomethingHappened.run(PerformableTree.java:285)
      ...

      Thanks a lot !

        Activity

        Mauro Talevi made changes -
        Field Original Value New Value
        Fix Version/s 4.0 [ 18486 ]
        Hide
        Mauro Talevi added a comment -

        Can you share the simplest sample project with your config that reproduces the problem?

        Show
        Mauro Talevi added a comment - Can you share the simplest sample project with your config that reproduces the problem?
        Hide
        Alexander Lehmann added a comment -

        to create a sample project, take the java-spring project from the tutorial and remove all steps except the first givenIAmOnEtsycom
        put just fail() in the the method.

        Then add the screenshot step to the spring bean xml file.

        Show
        Alexander Lehmann added a comment - to create a sample project, take the java-spring project from the tutorial and remove all steps except the first givenIAmOnEtsycom put just fail() in the the method. Then add the screenshot step to the spring bean xml file.
        Hide
        Damien LG added a comment - - edited

        Thanks for the answer !

        I just added this bean to the Spring config "etsy-steps.xml" :

        <bean id="screenshotOnFailureDriver" class="org.jbehave.web.selenium.WebDriverScreenshotOnFailure">
        <constructor-arg ref="driverProvider"/>
        </bean>

        I have just tried with a fresh clone from git, nothing change but new bean in spring and versions in POM :

        <jbehave.core.version>4.0-beta-2</jbehave.core.version>
        <jbehave.web.version>3.5.4</jbehave.web.version>
        <jbehave.site.version>3.1.1</jbehave.site.version>
        <fluent.selenium.version>1.6.3</fluent.selenium.version>
        <selenium.version>2.26.0</selenium.version>

        I have added a screenshot in attachments.

        Show
        Damien LG added a comment - - edited Thanks for the answer ! I just added this bean to the Spring config "etsy-steps.xml" : <bean id="screenshotOnFailureDriver" class="org.jbehave.web.selenium.WebDriverScreenshotOnFailure"> <constructor-arg ref="driverProvider"/> </bean> I have just tried with a fresh clone from git, nothing change but new bean in spring and versions in POM : <jbehave.core.version>4.0-beta-2</jbehave.core.version> <jbehave.web.version>3.5.4</jbehave.web.version> <jbehave.site.version>3.1.1</jbehave.site.version> <fluent.selenium.version>1.6.3</fluent.selenium.version> <selenium.version>2.26.0</selenium.version> I have added a screenshot in attachments.
        Damien LG made changes -
        Attachment ScreenShotFailure.png [ 62028 ]
        Hide
        Alexander Lehmann added a comment -

        I have tracked this down to a null parameter in PerfomableTree that should be the uuid exception if there is a failure.

        The diff below are my changes, not thoroughly tested, a unit test would be good (the screenshot now works for the esty test, but there may be more failures).

        The strange formatting is due to tabs in the source code, I can do a more elaborate diff maybe with a unit test later today when I have set up my git repositories again properly.

        diff --git a/jbehave-core/src/main/java/org/jbehave/core/embedder/PerformableTree.java b/jbehave-core/src/main/java/org/jbehave/core/embedder/PerformableTree.java
        index dcbd812..da9fc51 100644
        --- a/jbehave-core/src/main/java/org/jbehave/core/embedder/PerformableTree.java
        +++ b/jbehave-core/src/main/java/org/jbehave/core/embedder/PerformableTree.java
        @@ -848,7 +848,13 @@ public class PerformableTree {
                     results = new ArrayList<StepResult>();
                     for (Step step : steps) {
         				context.interruptIfCancelled();
        -				state = state.run(step, results, reporter, null);
        +				UUIDExceptionWrapper uuidFailure;
        +				if(state instanceof SomethingHappened) {
        +					uuidFailure = ((SomethingHappened)state).scenarioFailure;
        +				} else {
        +					uuidFailure = null;
        +				}
        +				state = state.run(step, results, reporter, uuidFailure);
                     }
                     context.stateIs(state);
                     List<PendingStep> pendingSteps = pendingSteps(steps);
        

        (two style questions:

        I think it would easier if the State interface had a method getScenarioFailure that returns null if it is not SomethingHappened, unless you prefer to keep the interface to the single method that is really implemented by both classes

        The if would be easier as ?: expression, unless we consider that statement undesirable

        state = state.run(step, results, reporter, state instanceof SomethingHappened ? ((SomethingHappened)state).scenarioFailure : null;
        

        )

        Show
        Alexander Lehmann added a comment - I have tracked this down to a null parameter in PerfomableTree that should be the uuid exception if there is a failure. The diff below are my changes, not thoroughly tested, a unit test would be good (the screenshot now works for the esty test, but there may be more failures). The strange formatting is due to tabs in the source code, I can do a more elaborate diff maybe with a unit test later today when I have set up my git repositories again properly. diff --git a/jbehave-core/src/main/java/org/jbehave/core/embedder/PerformableTree.java b/jbehave-core/src/main/java/org/jbehave/core/embedder/PerformableTree.java index dcbd812..da9fc51 100644 --- a/jbehave-core/src/main/java/org/jbehave/core/embedder/PerformableTree.java +++ b/jbehave-core/src/main/java/org/jbehave/core/embedder/PerformableTree.java @@ -848,7 +848,13 @@ public class PerformableTree { results = new ArrayList<StepResult>(); for (Step step : steps) { context.interruptIfCancelled(); - state = state.run(step, results, reporter, null ); + UUIDExceptionWrapper uuidFailure; + if (state instanceof SomethingHappened) { + uuidFailure = ((SomethingHappened)state).scenarioFailure; + } else { + uuidFailure = null ; + } + state = state.run(step, results, reporter, uuidFailure); } context.stateIs(state); List<PendingStep> pendingSteps = pendingSteps(steps); (two style questions: I think it would easier if the State interface had a method getScenarioFailure that returns null if it is not SomethingHappened, unless you prefer to keep the interface to the single method that is really implemented by both classes The if would be easier as ?: expression, unless we consider that statement undesirable state = state.run(step, results, reporter, state instanceof SomethingHappened ? ((SomethingHappened)state).scenarioFailure : null ; )
        Mauro Talevi made changes -
        Summary uuidWrappedFailure null when WebDriverScreenshotOnFailure @AfterScenario is called uuidWrappedFailure is null when failure occurs
        Component/s Core [ 11086 ]
        Component/s Web Selenium [ 14124 ]
        Mauro Talevi made changes -
        Assignee Mauro Talevi [ maurotalevi ]
        Hide
        Mauro Talevi added a comment -

        Implemented solution suggested by Alex and pushed 4.0-beta-3.

        Show
        Mauro Talevi added a comment - Implemented solution suggested by Alex and pushed 4.0-beta-3.
        Hide
        Damien LG added a comment -

        Ok fixed in 4.0-beta-3, thanks for the help !

        Show
        Damien LG added a comment - Ok fixed in 4.0-beta-3, thanks for the help !

          People

          • Assignee:
            Mauro Talevi
            Reporter:
            Damien LG
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated: