Can one Given When Then story drive > 1 JBhave Steps?

前端 未结 1 1278
北恋
北恋 2021-01-24 14:25

I\'ve created a .story file with a Given When Then (GWT).

Contact_List.story Scenario: Discover Contact Given I\'ve a contact list of friends When one of them is online

相关标签:
1条回答
  • 2021-01-24 15:22

    This is organized by the Configuration. In JBehave parlance, the Configuration is the class that tells the JBehave framework how to associate *.stories with *Steps.java. In the questioniers example, this is RunBDDTests.java. One option that will associate two steps with a single GWT scenario is to create two Configurations, one for the Service steps and one for the UI steps:

    ServiceConfiguration.java
    
    public class ServiceConfiguration extends JUnitStories
    {
     @Override
     public InjectableStepsFactory stepsFactory() {       
    
        return new InstanceStepsFactory(configuration(), new ServiceSteps()); // <- note steps class
     }
    
    @Override
    protected List<String> storyPaths() {
    
        return new StoryFinder().findPaths(CodeLocations.codeLocationFromClass(this.getClass()), "**/Contact_List.story", "");  //<- note story file name
    }
    }
    

    UIConfiguration.java

    public class UIConfiguration extends JUnitStories
    {
        @Override
        public InjectableStepsFactory stepsFactory() {              
          return new InstanceStepsFactory(configuration(), new UISteps()); // <- note steps class
        }
    
    @Override
    protected List<String> storyPaths() {       
      return new StoryFinder().findPaths(CodeLocations.codeLocationFromClass(this.getClass()), "**/Contact_List.story", "");  //<- note story file name
    }
    }
    

    The above two configurations will run two different step files against one .story.

    0 讨论(0)
提交回复
热议问题