2016-08-29 8 views
0

私はストーリーフォルダ内にjbehaveストーリーファイルはほとんどありません。スクリプトを実行するたびにアルファベット順に表示されます。どのように特定の順序でストーリーファイルを実行するのですか?BDD Jbehave

例: 現在の実行

aaa.story

bbb.story

ccc.story

私は実行になりたい

ccc.story

bbb.story

スキップaaa.story

特定の記事を特定の順序で実行する方法はありますか。 in Serenity BDD + Jbehave

答えて

1

Meta:を使用してストーリー/シナリオにタグを付けることができます。これは、ストーリー/シナリオのサブセットを実行したり、その一部をスキップしたりする場合に便利です。 例:

Meta: @sometag 

Scenario: some scenario 
Given something 

次にあなたが特定のタグでマークされたシナリオを包含/除外するmeta filteringstory mappingを使用することができます。

彼らの辞書式順序は、あなたがそれらを実行するために一致するように、あなたは物語のファイル名を変更することができます。もっと素敵なソリューションをするとき場合があり

a/aaa.story 
a/bbb.story 
c/ccc.story 

1_aaa.story 
2_bbb.story 
3_ccc.story 

または別のフォルダを作成します別のものの前に実行する話が必要です。GivenStories:句:

GivenStories: aaa.story 

Scenario: requires aaa to run 
Given something 

これは最初にこの物語の後にaaa.storyを実行します。 GivenStoriesに複数のストーリーを指定できます。

0

私はいくつかの似たようなシナリオを持っていますが、自分のカスタムThucydidesJUnitStoriesを作成していました。私の場合、それぞれのストーリーをステップごとに読み込み、競合を避ける必要がありました。例

public class CustomThucydidesJUnitStories extends ThucydidesJUnitStories { 

    Logger logger = LoggerFactory.getLogger(CustomThucydidesJUnitStories.class); 

    private Configuration configuration; 
    private List<Format> formats = Arrays.asList(CONSOLE, STATS, HTML); 

    @Test 
    @Override 
    public void run() throws Throwable { 
     List<String> storyPaths = storyPaths(); 
    logger.info("Total stories to run are {}", storyPaths.size()); 
     //HERE YOU CAN SORT THE storyPaths as you wish 
     for(String storyPath : storyPaths) { 
      Embedder embedder = configuredEmbedder(); 
      embedder.useConfiguration(configuration()); 
      String storyName = storyPath.substring(storyPath.lastIndexOf("/") + 1, storyPath.indexOf(".story")); 
      logger.info("Running story {}", storyName); 
      embedder.useStepsFactory(ThucydidesStepFactory.withStepsFromPackage(getRootPackage() + "." + storyName, configuration()).andClassLoader(getClassLoader())); 
      embedder.useEmbedderControls(ignoreFailsEmbedderControls()); 
      embedder.runStoriesAsPaths(Lists.newArrayList(storyPath)); 
     } 
    } 

    public EmbedderControls ignoreFailsEmbedderControls() { 
     return new EmbedderControls().doIgnoreFailureInStories(true).doIgnoreFailureInView(true); 
    } 

    @Override 
    public Configuration configuration() { 
     if (configuration == null) { 
      net.thucydides.core.webdriver.Configuration thucydidesConfiguration = getSystemConfiguration(); 
      configuration = ThucydidesJBehave.defaultConfiguration(thucydidesConfiguration, formats, this); 
     } 
     return configuration; 
    } 

} 
関連する問題