web-dev-qa-db-ja.com

MavenがTESTを2回実行するのを停止するにはどうすればよいですか?

私は約5000のテストケースを持つ大きなプロジェクトを持っています。実行時mvn clean installtestゴールを2回実行します(1回目はインストールの一部として、2回目はsurefireプラグインの一部として)。

なぜ2回目にtestを実行する必要があるのですか?そして、surefireに、それ自体を再起動する代わりにtestゴール結果を使用するように強制することはできますか?時間とマシンリソースの浪費だと思います。特に最近、testを実行する2回目のラウンドでPermGenビルドエラーが発生し、Mavenランナーにいくらヒープをポンプしても死んでしまいます。 2回目のテストラウンドで。

これは私の確実なプラグ構成です:

 <plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.18.1</version>
    <executions>
       <execution>
         <id>default-test</id>
         <phase>test</phase>
         <goals>
             <goal>test</goal>
         </goals>
         <configuration>
            <parallel>classes</parallel>
            <threadCount>3</threadCount>
         </configuration>
      </execution>
   </executions>
</plugin>

プラグインを微調整してマシンリソースをより適切に処理する方法はありますか?

実行される完全なデフォルトのMavenプロファイルは次のとおりです。

<build>
    <plugins>
        <plugin>
            <groupId>org.Apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
                <archive>
                    <manifest>
                        <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                    </manifest>
                    <manifestEntries>
                        <Build-Number>${build.number}</Build-Number>
                        <Job-Name>${job.name}</Job-Name>
                        <Build-Url>${build.url}</Build-Url>
                        <Git-Commit>${git.commit}</Git-Commit>
                        <Git-Branch>${git.branch}</Git-Branch>
                        <Timestamp>${maven.build.timestamp}</Timestamp>
                        <StyleGuide-Version>${styleguide.version}</StyleGuide-Version>
                    </manifestEntries>
                </archive>
                <warName>pss</warName>
            </configuration>
        </plugin>
        <plugin>
            <groupId>com.cj.jshintmojo</groupId>
            <artifactId>jshint-maven-plugin</artifactId>
            <version>1.3.0</version>
            <executions>
                <execution>
                    <goals>
                        <goal>lint</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <options>maxparams:5,camelcase,eqeqeq,forin,immed,latedef,noarg,noempty,nonew,expr</options>
                <directories>
                    <directory>src/main/webapp/js/page</directory>
                </directories>
                <excludes>
                    <exclude>src/main/webapp/js/page/marketingPreferences.js</exclude>
                    <exclude>src/main/webapp/js/page/changeCarParkingDetails.js</exclude>
                    <exclude>src/main/webapp/js/page/angularjs-app.js</exclude>
                    <exclude>src/main/webapp/js/page/content-cover.js</exclude>
                    <exclude>src/main/webapp/js/page/amendmentConfirm.js</exclude>
                </excludes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.lesscss</groupId>
            <artifactId>lesscss-maven-plugin</artifactId>
            <version>1.3.3</version>
            <executions>
                <execution>
                    <id>bingleless</id>
                    <configuration>
                        <sourceDirectory>${project.basedir}/src/main/webapp/app-resources/</sourceDirectory>
                        <outputDirectory>${project.basedir}/src/main/webapp/app-resources/</outputDirectory>
                        <includes>
                            <include>**\/policy-self-service\/**\/*pss-sg.less</include>
                        </includes>
                        <compress>true</compress>
                    </configuration>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>net.alchim31.maven</groupId>
            <artifactId>yuicompressor-maven-plugin</artifactId>
            <version>1.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>compress</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <excludes>
                    <exclude>**/*.min.js</exclude>
                    <exclude>**/*.min.css</exclude>
                    <exclude>**/style-guide/**</exclude>
                    <exclude>**/generated/**</exclude>
                    <exclude>**/app-resources/common/**</exclude>
                    <exclude>**/app-resources/bower_components/**</exclude>
                    <exclude>**/app-resources/policy-self-service/**</exclude>
                </excludes>
                <nosuffix>true</nosuffix>
                <jswarn>false</jswarn>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.Apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <configuration>
                <logViolationsToConsole>true</logViolationsToConsole>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${maven-surefire-plugin.version}</version>
            <configuration>
                <parallel>classes</parallel>
                <threadCount>3</threadCount>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.Apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <version>${maven-surefire-report-plugin.version}</version>
            <executions>
                <execution>
                    <phase>install</phase>
                    <goals>
                        <goal>report-only</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
13
DhafirNz

<execution>pom.xmlが2回目のテスト実行を引き起こすと思います。 Mavenは、テストフェーズのデフォルトの目標に加えて、実行する別の目標と見なしています。

maven-surefire-pluginはテストフェーズでMavenでデフォルトで使用されるプラグインであるため、<configuration>の外に<execution>部分を指定するだけで済みます。 pom.xmlを以下のように変更します

<plugins>
  <plugin>
    <groupId>org.Apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.18.1</version>
    <configuration>
        <parallel>classes</parallel>
        <threadCount>3</threadCount>
    </configuration>
  </plugin>
</plugins>
6
Rocherlee