JBehave
  1. JBehave
  2. JBEHAVE-1059

NPE during run tests in other languages

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 3.9.3, 3.9.4, 3.9.5
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None
    • Environment:
      Win7 x64
      java version "1.7.0_51"
      Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
    • Number of attachments :
      1

      Description

      I have a simple project Jbehave + Thucydides from archetype: net.thucydides:thucydides-jbehave-archetype.
      And I modified class de.jbehave.AcceptanceTestSuite to change the locale of the test for other language e.x. German

      package de.jbehave;
      
      import net.thucydides.jbehave.ThucydidesJUnitStories;
      import net.thucydides.jbehave.UTF8StoryLoader;
      
      import java.util.Locale;
      
      import org.jbehave.core.Embeddable;
      import org.jbehave.core.configuration.Configuration;
      import org.jbehave.core.configuration.Keywords;
      import org.jbehave.core.i18n.LocalizedKeywords;
      import org.jbehave.core.parsers.RegexStoryParser;
      
      public class AcceptanceTestSuite extends ThucydidesJUnitStories {
      
      private final Locale DEFAULTSTORYLANGUAGE = new Locale("de");
      
      @Override
          public Configuration configuration() {
              Configuration configuration = super.configuration();
              Class<? extends Embeddable> embeddableClass = this.getClass();
      
              //Set stories and return report to French
              Keywords keywords = new LocalizedKeywords(DEFAULTSTORYLANGUAGE);
              configuration.useKeywords(keywords)//
                  .useStoryParser(new RegexStoryParser(keywords))
                      .useStoryLoader(new UTF8StoryLoader())
                      .storyReporterBuilder().withKeywords(keywords);
              return  configuration;
          }
      
      }
      

      Also I modified story file

      Szenario: Looking up the definition of 'apple'
      Gegeben the user is on the Wikionary home page
      Wenn the user looks up the definition of the word 'apple'
      Dann they should see the definition 'A common, round fruit produced by the tree Malus domestica, cultivated in temperate climates.'
      
      Szenario: Looking up the definition of 'pear'
      Gegeben the user is on the Wikionary home page
      Wenn the user looks up the definition of the word 'pear'
      Dann they should see the definition 'An edible fruit produced by the pear tree, similar to an apple but elongated towards the stem.'
      

      I ran the tests.
      Until now everything looked fine but when I added Exmaples Table in story file:

      Szenario: Looking up the definition of '<word>'
      Gegeben the user is on the Wikionary home page
      Wenn the user looks up the definition of the word '<word>'
      Dann they should see the definition '<definition>'
      Beispiele:
      | word  | definition    |
      | apple  | A common, round fruit produced by the tree Malus domestica, cultivated in temperate climates. |
      
      Szenario: Looking up the definition of 'pear'
      Gegeben the user is on the Wikionary home page
      Wenn the user looks up the definition of the word 'pear'
      Dann they should see the definition 'An edible fruit produced by the pear tree, similar to an apple but elongated towards the stem.'
      

      Next time NPE occurred:

      TEST STARTED: Looking up the definition of '<word>'
      --------------------------------------------------------------------
      Szenario: Looking up the definition of '<word>'
      Beispiele:
      Gegeben the user is on the Wikionary home page
      Wenn the user looks up the definition of the word '<word>'
      Dann they should see the definition '<definition>'
      
      |word|definition|
      |apple|A common, round fruit produced by the tree Malus domestica, cultivated in
       temperate climates.|
      
      Beispiel: {word=apple, definition=A common, round fruit produced by the tree Mal
      us domestica, cultivated in temperate climates.}
      Failed to run story de/stories/consult_dictionary/LookupADefinition.story
      java.lang.NullPointerException
              at de.codecentric.jbehave.junit.monitoring.JUnitScenarioReporter.example
      (JUnitScenarioReporter.java:197)
              at org.jbehave.core.reporters.DelegatingStoryReporter.example(Delegating
      StoryReporter.java:91)
              at org.jbehave.core.reporters.ConcurrentStoryReporter.example(Concurrent
      StoryReporter.java:209)
              at org.jbehave.core.embedder.StoryRunner.runScenariosParametrisedByExamp
      les(StoryRunner.java:429)
              at org.jbehave.core.embedder.StoryRunner.runCancellable(StoryRunner.java
      :303)
              at org.jbehave.core.embedder.StoryRunner.run(StoryRunner.java:220)
              at org.jbehave.core.embedder.StoryRunner.run(StoryRunner.java:181)
              at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManage
      r.java:262)
              at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManage
      r.java:229)
              at java.util.concurrent.FutureTask.run(FutureTask.java:262)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
      java:1145)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
      .java:615)
              at java.lang.Thread.run(Thread.java:744)
      Before storyAfterStories
      

      Workaround
      Put file https://github.com/jbehave/jbehave-core/blob/master/jbehave-core/src/main/resources/i18n/keywords_de.properties in your project in /src/main/resources/i18n/ with change one line:

      ExamplesTableRow=Example:
      

        Activity

        Hide
        Mauro Talevi added a comment -

        This NPE does not occur in the JBehave code but in the codecentric code.

        You should raise the issue with them.

        Show
        Mauro Talevi added a comment - This NPE does not occur in the JBehave code but in the codecentric code. You should raise the issue with them.
        Hide
        Tomasz Uss added a comment -

        @Mauro Talev, thx for the analysis. I created a ticket https://github.com/codecentric/jbehave-junit-runner/issues/72.

        Show
        Tomasz Uss added a comment - @Mauro Talev, thx for the analysis. I created a ticket https://github.com/codecentric/jbehave-junit-runner/issues/72 .

          People

          • Assignee:
            Unassigned
            Reporter:
            Tomasz Uss
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: