JBehave
  1. JBehave
  2. JBEHAVE-1015

Outcomes table doesn't work with a boolean comparison that is false

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None
    • Number of attachments :
      0

      Description

      This outcome:

      outcomes.addOutcome("Test", true, equalTo(false));

      gives this error:

      Error on line 94, column 100 in ftl/jbehave-html-output.ftl Expecting a string, date or number here, Expression value is instead a freemarker.ext.beans.BooleanModel The problematic instruction: ---------- ==> $

      {value?html}

      [on line 94, column 98 in ftl/jbehave-html-output.ftl] in user-directive renderOutcomeValue [on line 88, column 41 in ftl/jbehave-html-output.ftl] in user-directive renderOutcomes [on line 100, column 23 in ftl/jbehave-html-output.ftl] in user-directive renderStep [on line 138, column 1 in ftl/jbehave-html-output.ftl] ---------- Java backtrace for programmers: ---------- freemarker.core.NonStringException: .....

      it works with true/true.

        Activity

        Hide
        Mauro Talevi added a comment -

        Not able to reproduce with JDK 1.7.0_40 and freemarker 2.3.19.

        What's you're env like?

        Show
        Mauro Talevi added a comment - Not able to reproduce with JDK 1.7.0_40 and freemarker 2.3.19. What's you're env like?
        Hide
        Michael M added a comment -

        Hi Mauro,

        I'm using JDK 1.7.0_51, jbehave 3.9.2 and freemarker 2.3.19. As far as I know, our jBehave configuration hasn't changed in the past week.

        I'm attaching the log file with the full stack trace when run with Maven. I'm not familiar with freemarker, but the line in the .ftl file is this:

        <#macro renderOutcomeValue value dateFormat><#if value?is_date>$

        {value?string(dateFormat)}<#else>${value?html}</#if></#macro>

        and the value?html is failing for a type of BooleanModel:

        Expecting a string, date or number here, Expression value is instead a freemarker.ext.beans.BooleanModel

        I googled this error and I found many hits, most of them from several years ago. I didn't find a solution. So as a temporary workaround, I modified the FTL to add another #if and if it's boolean I use value?string and if it's not boolean I use value?html. It seems the html doesn't work for boolean. But I don't know what is causing it not to work.

        Here's my temp fix:

        <#macro renderOutcomeValue value dateFormat><#if value?is_date>${value?string(dateFormat)}

        <#else><#if value?is_boolean>$

        {value?string}

        <#else>$

        {value?html}

        </#if></#if></#macro>

        Show
        Michael M added a comment - Hi Mauro, I'm using JDK 1.7.0_51, jbehave 3.9.2 and freemarker 2.3.19. As far as I know, our jBehave configuration hasn't changed in the past week. I'm attaching the log file with the full stack trace when run with Maven. I'm not familiar with freemarker, but the line in the .ftl file is this: <#macro renderOutcomeValue value dateFormat><#if value?is_date>$ {value?string(dateFormat)}<#else>${value?html}</#if></#macro> and the value?html is failing for a type of BooleanModel: Expecting a string, date or number here, Expression value is instead a freemarker.ext.beans.BooleanModel I googled this error and I found many hits, most of them from several years ago. I didn't find a solution. So as a temporary workaround, I modified the FTL to add another #if and if it's boolean I use value?string and if it's not boolean I use value?html. It seems the html doesn't work for boolean. But I don't know what is causing it not to work. Here's my temp fix: <#macro renderOutcomeValue value dateFormat><#if value?is_date>${value?string(dateFormat)} <#else><#if value?is_boolean>$ {value?string} <#else>$ {value?html} </#if></#if></#macro>
        Hide
        Mauro Talevi added a comment -

        Could you please try to reproduce this problem by adding a story or scenario in the core examples?

        Show
        Mauro Talevi added a comment - Could you please try to reproduce this problem by adding a story or scenario in the core examples?
        Hide
        Michael M added a comment -

        Will try to make an example on Friday.

        Show
        Michael M added a comment - Will try to make an example on Friday.
        Hide
        Michael M added a comment -

        Ok it works in the jbehave core examples. I put it in one of the trader stories:

        Scenario: Test boolean

        Given true is true (FAILED)
        org.jbehave.core.model.OutcomesTable$OutcomesFailed
        Description Value Matcher Verified
        Test Boolean1 true <true> Yes
        Test Boolean2 true <false> No
        org.jbehave.core.model.OutcomesTable$OutcomesFailed
        at org.jbehave.core.model.OutcomesTable.verify(OutcomesTable.java:55)
        at org.jbehave.examples.core.steps.TraderSteps.trueIsTrue(TraderSteps.java:190)
        (reflection-invoke)
        at org.jbehave.core.steps.StepCreator$ParametrisedStep.perform(StepCreator.java:583)
        at org.jbehave.core.embedder.StoryRunner$FineSoFar.run(StoryRunner.java:535)

        I then pasted the same scenario into my project (with the step) and it has the same problem.

        I suspect it might be a problem with the dependencies but I really don't know.

        Show
        Michael M added a comment - Ok it works in the jbehave core examples. I put it in one of the trader stories: Scenario: Test boolean Given true is true (FAILED) org.jbehave.core.model.OutcomesTable$OutcomesFailed Description Value Matcher Verified Test Boolean1 true <true> Yes Test Boolean2 true <false> No org.jbehave.core.model.OutcomesTable$OutcomesFailed at org.jbehave.core.model.OutcomesTable.verify(OutcomesTable.java:55) at org.jbehave.examples.core.steps.TraderSteps.trueIsTrue(TraderSteps.java:190) (reflection-invoke) at org.jbehave.core.steps.StepCreator$ParametrisedStep.perform(StepCreator.java:583) at org.jbehave.core.embedder.StoryRunner$FineSoFar.run(StoryRunner.java:535) I then pasted the same scenario into my project (with the step) and it has the same problem. I suspect it might be a problem with the dependencies but I really don't know.
        Hide
        Mauro Talevi added a comment -

        Can you provide a sample project reproducing the issue then?

        Show
        Mauro Talevi added a comment - Can you provide a sample project reproducing the issue then?
        Hide
        Michael M added a comment -

        I can try on Monday. Do you think it's worthwhile? I seem to be the only one having it and the workaround in the FTL was easy enough.

        Show
        Michael M added a comment - I can try on Monday. Do you think it's worthwhile? I seem to be the only one having it and the workaround in the FTL was easy enough.
        Hide
        Mauro Talevi added a comment -

        It could be interesting to understand the source of the issue.

        Show
        Mauro Talevi added a comment - It could be interesting to understand the source of the issue.
        Hide
        Michael M added a comment -

        I ruled out our POM & dependencies. That leaves the customizations to run the story, which is quite complex to try and troubleshoot it.

        Show
        Michael M added a comment - I ruled out our POM & dependencies. That leaves the customizations to run the story, which is quite complex to try and troubleshoot it.
        Hide
        Mauro Talevi added a comment -

        It's rather strange. Can you share elements for your story customisation?

        You could also try to run the FTL by the FreemarkerProcessor in a simple unit test to see if you can reproduce issue.

        Show
        Mauro Talevi added a comment - It's rather strange. Can you share elements for your story customisation? You could also try to run the FTL by the FreemarkerProcessor in a simple unit test to see if you can reproduce issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Michael M
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: