我有大約5000個測試用例的大項目。在運行mvn clean install
時,它將兩次運行test
目標(其中一個作爲安裝的一部分,第二次作爲surefire
插件的一部分)。如何停止運行兩次測試的maven?
爲什麼需要第二次運行test
?並且在那裏強迫surefire
使用test
目標結果而不是重新調用它自己的結果? 我認爲這是浪費時間和機器資源,特別是最近第二輪運行test
造成PermGen
構建錯誤,無論我將多大的堆泵入maven runner,它仍然會在第二輪測試中死亡。
這是我的神火pluging配置:
<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>
您是否嘗試刪除執行部分? – Zelldon
請添加(trimmed)'mvn clean install'的輸出,特別是以'[INFO] - maven-surefire-plugin'開頭的行 - 應該幫助追蹤插件何時執行和執行多少次。 –
它只運行一次,你有其他插件嗎? – ravthiru