2016-08-08 11 views
0

Jenkinsでmavenビルドを実行すると実行されるJbehaveテストの数が実行ごとに異なることがあることに気付きました。ログを分析するとき、私は次のコードを参照してください。テストが実行されなかったときにMavenビルドが失敗することを確認します

Failed to run story stories/cancel.story 
java.lang.InterruptedException: stories/cancel.story 
    at org.jbehave.core.embedder.StoryRunner$RunContext.interruptIfCancelled(StoryRunner.java:616) 
    at org.jbehave.core.embedder.StoryRunner.runStepsWhileKeepingState(StoryRunner.java:514) 
    at org.jbehave.core.embedder.StoryRunner.runScenarioSteps(StoryRunner.java:479) 
    at org.jbehave.core.embedder.StoryRunner.runStepsWithLifecycle(StoryRunner.java:445) 
    at org.jbehave.core.embedder.StoryRunner.runCancellable(StoryRunner.java:305) 
    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(StoryManager.java:235) 
    at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:207) 
    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:745) 

問題は、テストがスキップされたときにビルドがまだ成功とみなされ、このように実行に失敗したりということです。

テストで失敗したビルド結果をテストが失敗するたびに確実に行うmaven surefireプラグインの設定はありますか?ここではMavenの確実なビルド構成が

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.11</version> 
      <configuration> 
       <skip>true</skip> 
      </configuration> 
     </plugin> 
     <plugin> 
      <artifactId>maven-failsafe-plugin</artifactId> 
      <version>2.11</version> 
      <configuration> 
       <includes> 
        <include>**/*TestSuite.java</include> 
       </includes> 
      </configuration> 
      <executions> 
       <execution> 
        <goals> 
         <goal>integration-test</goal> 
         <goal>verify</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.1</version> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-javadoc-plugin</artifactId> 
      <version>2.9</version> 
     </plugin> 
     <plugin> 
      <groupId>net.thucydides.maven.plugins</groupId> 
      <artifactId>maven-thucydides-plugin</artifactId> 
      <version>${thucydides.version}</version> 
      <executions> 
       <execution> 
        <id>thucydides-reports</id> 
        <phase>post-integration-test</phase> 
        <goals> 
         <goal>aggregate</goal> 
        </goals> 
       </execution> 
      </executions> 
      <dependencies> 
       <dependency> 
        <groupId>log4j</groupId> 
        <artifactId>log4j</artifactId> 
        <version>1.2.17</version> 
       </dependency> 
      </dependencies> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-site-plugin</artifactId> 
      <version>3.2</version> 
      <configuration> 
       <reportPlugins> 
        <plugin> 
         <groupId>net.thucydides.maven.plugins</groupId> 
         <artifactId>maven-thucydides-plugin</artifactId> 
         <version>${thucydides.version}</version> 
        </plugin> 
       </reportPlugins> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

答えて

0

あるごmaven-surefire-pluginは(<skip>true</skip>で)完全にテストをスキップするように設定されているので、テストがmaven-failsafe-pluginで実行されています。このプラグインは、integration-testの間に失敗したときに停止してはならず、verifyフェーズでのみ失敗します。

だから、あなたは本当にこの質問に答えたい場合:

は、テストが失敗にビルド結果を実行に失敗したときにことを保証しますMavenの確実なプラグインの設定はありますか?ある

:あなたはmaven-surefire-pluginは、テストを実行したい、としませmaven-failsafe-plugin、そして答えは:あなたのPOMから

 <configuration> 
      <skip>true</skip> 
     </configuration> 

を削除します。この場合は、maven-failsafe-pluginの設定は必要ありません。これは、テストを2回だけ実行するためです。

しかし、あなたの目標はmaven-failsafe-pluginが仕事を得るのであれば、その後、私はあなたが次の問題の1持っているかもしれないと思う:

  1. は、右の目標を実行していないし。プラグインhelp statesとして、あなたは(現在のバージョンは2.19.1ある)

  2. またはこのヘルプ勧告を使用している

    mvn verify 
    
  3. として古いプラグイン、テストフレームワークと互換性がありませんそれを呼び出す必要があります:

    0:非常に複雑なために

    ビルド、統合テストの実行を分離し、目標を検証する方が良いかもしれ

    <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-failsafe-plugin</artifactId> 
        <version>2.19.1</version> 
        <executions> 
        <execution> 
         <id>integration-test</id> 
         <goals> 
         <goal>integration-test</goal> 
         </goals> 
        </execution> 
        <execution> 
         <id>verify</id> 
         <goals> 
         <goal>verify</goal> 
         </goals> 
        </execution> 
        </executions> 
    </plugin> 
    
+0

私はこの仕事ができると思いますが、私は探していたものは、 3000> – RodN

+0

あなたはmaven-failsafe-pluginを使用しているので、一般的なストーリーやjbehaveを知らないでテストを総括的に実行します(その観点から見ると、別のJUnit/TestNGテストです)。コマンドラインパラメータとして渡す場合、JBehaveが読むことができることを知っているなら、 ' -Dyour.param = ...'でそれを行うことができます。しかし、また:フェイルセーフの代わりに 'jbehave-maven-plugin'を使ってテストを実行することを検討しましたか?それは 'storyTimeoutInSecs'を持っているようです:http://jbehave.org/reference/stable/maven-goals.html –

関連する問題