質問

ようになっMavenビルドの実行の最もユニット。がユニット試験は一つのプロジェクトは遅ていただきたいと思いますように一般的に排除し時にはまっております。

質問:いるのか?

知って -Dmaven.test.skip=true, がoffすべてのユニット。

私も知ら飛び統合の試験の記述 こちらの.はありませんの統合の試験は、単体テストは、まったく泳げないんだけど---明示的な呼maven必ずうまくいく-引き出しおよび設定ができます(私が使っていMaven2のEclipse-Mavenプラグイン).

役に立ちましたか?

解決

何かいつも飛び試験だけがこのモジュール?

のpom.xml このモジュール:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.4.2</version>
        <configuration>
          <skipTests>true</skipTests>
        </configuration>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

最終的には、できるプロファイルを作成するとする試験のpom.xml のモジュール):

<project>
  [...]
  <profiles>
    <profile>
      <id>noTest</id>
      <activation>
        <property>
          <name>noTest</name>
          <value>true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.4.2</version>
            <configuration>
              <skipTests>true</skipTests>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
  [...]
</project>

後の溶液に、走らせる場合 mvn clean package, で走っている。ご mvn clean package -DnoTest=true, まずは試験のためのモジュールです。

他のヒント

いや、ものの作業のための非必ずうまくいく試験(私の場合、FlexUnitTests)

<profile>
   <id>noTest</id>
    <properties>
       <maven.test.skip>true</maven.test.skip>
    </properties>
 </profile>

また大型マルチモジュール-プロジェクトというスキップ試験だけにあるモジュールの変更が必要なそれぞれのモジュール pom.xml ファイルをカスタム設定やプロファイリング、以下のように追加の親会社 pom.xml ファイル:

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.12</version>
            <executions>
                <execution>
                    <id>regex-property</id>
                    <goals>
                        <goal>regex-property</goal>
                    </goals>
                    <configuration>
                        <name>maven.test.skip</name>
                        <value>${project.artifactId}</value>
                        <regex>(module1)|(module3)</regex>
                        <replacement>true</replacement>
                        <failIfNoMatch>false</failIfNoMatch>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
<modules>
    <module>module1</module>
    <module>module2</module>
    <module>module3</module>
</modules>

さら build-helper-maven-plugin すう動的に確認できるモジュールなの構築を通じて project.artifactId 財(指各 artifactId モジュールの構築、regexうから信頼される組織を目指すマッチングのための一定の値(モジュール名にするスキップ試験)の人口に maven.test.skip 物件取得の設定で true).

この場合、試験するためのスキップ module1module3 走りながら適切に module2, であるとして表現し、regex.

このアプローチの利点について動的-集中(親会 pom.xml)このためよりよい。きの追加と削除モジュールで時間を変更するだけで、簡単な正規表現です。

明らかにない場合のデフォルトの動作の構築(推奨)、または常にラップのスニペットの上に mavenプ.


きも強い動的挙動に基づく入力:

<properties>
    <test.regex>none</test.regex>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.12</version>
            <executions>
                <execution>
                    <id>regex-property</id>
                    <goals>
                        <goal>regex-property</goal>
                    </goals>
                    <configuration>
                        <name>maven.test.skip</name>
                        <value>${project.artifactId}</value>
                        <regex>${test.regex}</regex>
                        <replacement>true</replacement>
                        <failIfNoMatch>false</failIfNoMatch>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

ここでは実際に置換の正規表現の値と有 test.regex, は、デフォルト値 none (あい合わせのモジュール名は、デフォルトの飛びマッチングが行が必要です。

それからコマンドラインにて

mvn clean test -Dtest.regex="(module1)" > will skip tests only for module1
mvn clean test -Dtest.regex="(module1)|(module2)" > will skip tests on module1 and module2
mvn clean test -Dtest.regex="(module1)|(module2)|(module3)" > will skip the three module tests
mvn clean test -Dtest.regex=".+" > will skip all module tests
mvn clean test > would not skip anything (or fall back on default behavior)

その後、実行時に決まりましたら、変更が必要なの pom.xml ファイルまたは活性化せます。

また少し違うからこの問いることを証明す。たいと思ったから除外するコマンドライン、くつかの異なる試験が異なるパッケージ、シングルワイルドカードなんです。

このMavenローカルフェールセーフの文書のルールを除を指定できるコンマで区切ったリストの正規表現のいずれかまたはワイルドカードを除:https://maven.apache.org/surefire/maven-failsafe-plugin/examples/inclusion-exclusion.html

このような中、私pomfileように見えます:

<excludes>
    <exclude>${exclude.slow.tests}</exclude>
</excludes>

私のコマンドラインに含まれます:

mvn install "-Dexclude.slow.tests=**/SlowTest1.java, **/package/ofslowtests/*.java, **/OtherSlowTest.java"

私にとっての重要な要素っ気試験を一つのmavenプロパティはシングルは除きます。

を必ずうまくいくプラグイン2.19できるだけ排除の実験によってお使いの正規表現を使用して:

mvn '-Dtest=!%regex[.*excludedString.*]' test

上記のコマンドを除くすべての試験を含む excludedString.

NB1 場合はダブルクォーテーション(")が使用されているの引用符(')をコマンドは適切に解釈されますみます。(試用bash3.2.57)

NB2 には特に注意が必要であると述べるプロジェクトに複数の版は、必ずうまくいくプラグインを使用します。バージョンの必ずうまくいくよ2.19な実施の試験にも対応していない正規表現オブジェクト

バージョン管理(かもいいかもこの機能を追加は、親会pomファイル):

<build>
  <pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.19.1</version>
      </plugin>
    </plugins>
  </pluginManagement>
</build>

例buildコマンドをスキップ試験: https://artbcode.wordpress.com/2016/11/28/how-to-skip-a-subset-of-the-unit-tests/

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top