2012-02-17 15 views
2

私たちは、どのように私は、この個々のテストを実行することができますMavenで個々のテストを実行するにはどうすればよいですか?

./src/test/java/com/myco/clearing/common/xml/TextNodeTest.java 

...私たちは、このテストファイルを持っている...

<dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.8.1</version> 
     <scope>test</scope> 
    </dependency> 

をMavenの3.0.3を使用しているとJUnit 4.8.1を使用していますか?試してみると

mvn -Dtest=TextNodeTest test 

私はテストが実行されなかったというエラーが表示されます。テスト全体にパッケージ名全体を指定すると、同じエラーが発生します。 ...

エラーメッセージが生成さ
mvn clean -Dtest=com.myco.clearing.common.xml.TextNodeTest test 

...ここ

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project myco-productplus-web: No tests were executed! 
(Set -DfailIfNoTests=false to ignore this error.) -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException 

は、それが2.12バージョンのバグだように、私は

 <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.12</version> 
      <configuration> 
       <skip>false</skip> 
       <additionalClasspathElements> 
        <additionalClasspathElement>${project.build.sourceDirectory}</additionalClasspathElement> 
        <additionalClasspathElement>${project.build.testSourceDirectory}</additionalClasspathElement> 
       </additionalClasspathElements> 
       <useManifestOnlyJar>false</useManifestOnlyJar> 
       <forkMode>always</forkMode> 
       <systemProperties> 
        <property> 
         <name>gwt.args</name> 
         <value>-out "${webappDirectory}"</value> 
        </property> 
       </systemProperties> 
       <systemPropertyVariables> 
        <tomcat.port>${tomcat.servlet.port}</tomcat.port> 
        <project.artifactId>${project.artifactId}</project.artifactId> 
       </systemPropertyVariables> 
      </configuration> 
     </plugin> 
+0

デイブは、2.11にダウングレードしましたか? –

答えて

2

を使用しています確実な設定が見えるです - SUREFIRE-827。 2.11にダウングレードしてみてください。確実な中で、単一のテスト(メソッド)を実行するための

5

方法が行うことです。

mvn test -Dtest=uk.co.farwell.AppTest#testSlow 

ではなく、クラス名やメソッド名の間にスペースの#に注意してください。

@Andrewによれば、2.12(SUREFIRE-827: Surefire 2.12 cannot run a single test, regression from 2.11)にバグがありますが、2.11で動作します。

上記のバグはまだ開いています(2012年2月24日現在)。実際には2.13-SNAPSHOTを使用して私の作品になります。

編集:これは2.12.1で修正済みとマークされました。

0

他の人が言うように、Surefireのバグであり、はバージョン2.11.1から修正されています。