Junit4とTestNG一つのプロジェクトMaven
質問
走とが少ないオプションが限定されていないの異なるプロファイル程度php,c#,dに、TestNG.この問題は、とを除くと試験を含む。
場合があるのを追加しましたtestNG依存性本プロジェクトのプロトコルでスキップすべての字句いうことについて決議しましたので別す。私を除くTestNG試験のデフォルト(メイン)プロファイルの編集を以下のエントリpom.xml :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<testExcludes>
<testExclude>**/tests/**.*</testExclude>
<testExclude>**/tests/utils/**.*</testExclude>
</testExcludes>
</configuration>
</plugin>
同じめ必ずうまくいくの引き出しおよび設定ができますその作品は微細なプロファイルを実行しみJunit4。が使っていtestNG profileそもそも太陽系つ実行testNG試験でもそもそも太陽系コンパイルします。を使用してい下記のプロファイル実行しています。
<profile>
<id>testNG</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<testIncludes>
<testInclude>**/tests/**.java</testInclude>
<testInclude>**/tests/utils/**.*</testInclude>
</testIncludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>false</skip>
<includes>
<include>**/**.class</include>
<include>**/tests/utils/**.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.8</version>
<scope>test</scope>
<classifier>jdk15</classifier>
</dependency>
</dependencies>
</profile>
もう理由ではなく、編集。
解決
コンパイラプラグインの設定は、TestNGのタイプを除外します。プロファイルからの設定はデフォルトの設定と合併し、ので、あなたの効果的なコンパイラの構成はされます:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<testIncludes>
<testInclude>**/tests/**.java</testInclude>
<testInclude>**/tests/utils/**.*</testInclude>
</testIncludes>
<testExcludes>
<testExclude>**/tests/**.*</testExclude>
<testExclude>**/tests/utils/**.*</testExclude>
</testExcludes>
</configuration>
</plugin>
これはあなたのTestNGのタイプはこれまでにコンパイルされていないため、実行されていないことを意味します。
あなたは<除外>を指定した場合はTestNGのセクションは、それがコンパイルされ、実行されるデフォルト除外して、TestNGのタイプを上書きしますプロファイル。それは空の除外タグ(すなわち<除外/>)で動作するかどうか、私は覚えていないことは、デフォルトの設定が上書きされていることを確認するために、このようなものを指定する必要があります。
<testExcludes>
<testExclude>dummy</testExclude>
</testExcludes>
他のヒント
最も簡単なソリューションは、このようなものです。
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>${surefire.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>${surefire.version}</version>
</dependency>
</dependencies>
</plugin>
これについては詳細情報:<のhref = "http://solidsoft.wordpress.com/2013/03/12/mixing-testng-and-junit-tests-in-one-maven-module-2013-edition /」のrel = "nofollowを"> 1 MavenのモジュールでTestNGのとJUnitテストをミキシング -
2013 で私からの複合溶液をオンラインにも必ずうまくいく、万.のPOMファイルの変化の下で働きました。
- は必ずうまくいくコツは明示的に指定するの子プラグインの両方の程度php,c#,dに、TestNG.
- のフェールセーフトリックによる定義につ死刑を執り、それぞれの空の設定は、JUnitのTestNG.
両解hacksした。私へのリンクは必ずうまくいくコツは、他に答えます。
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>${surefire.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>${surefire.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${failsafe.version}</version>
<executions>
<execution>
<id>test-testng</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<testNGArtifactName>none:none</testNGArtifactName>
</configuration>
</execution>
<execution>
<id>test-junit</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<junitArtifactName>none:none</junitArtifactName>
</configuration>
</execution>
</executions>
</plugin>
<!-- ... -->
</plugins>