我有一个具有单元和集成测试的项目。我有两个测试套件:
@RunWith(ClasspathSuite.class)
@ClasspathSuite.ClassnameFilters({ ".*Test", "!.*IntegrationTest", "!.*ResourceTest", "!.*DAOTest" })
@ClasspathSuite.SuiteTypes({ SuiteType.JUNIT38_TEST_CLASSES, SuiteType.TEST_CLASSES, SuiteType.RUN_WITH_CLASSES })
public class AutoTestSuite {
}
在大约 20 秒内运行 70 次测试
@RunWith(ClasspathSuite.class)
@ClasspathSuite.SuiteTypes({ SuiteType.JUNIT38_TEST_CLASSES, SuiteType.TEST_CLASSES, SuiteType.RUN_WITH_CLASSES })
@ClasspathSuite.ClassnameFilters({ ".*IntegrationTest" })
public class IntegrationTestSuite {
}
它在大约 80 秒内运行 99 个集成测试。
这很好,但是当我尝试在本地和 Jenkins 内部运行我的 maven 构建时,测试数字在 12-18 分钟之间运行 348 个测试。显然是我的 pom.xml,甚至考虑到 jacoco 来检查。谁能看到我用“ mvn clean package调用的以下内容有什么问题:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.0.201210061924</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>jacoco.argLine.unit</propertyName>
<destFile>${jacoco.destFile.unit}</destFile>
</configuration>
</execution>
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>jacoco.argLine.it</propertyName>
<destFile>${jacoco.destFile.it}</destFile>
</configuration>
</execution>
</executions>
</plugin>
<!-- UNIT tests only with mvn clean test -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${version.surefire}</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>${version.surefire}</version>
</dependency>
</dependencies>
<configuration>
<argLine>${jacoco.argLine.unit}
-Dfile.encoding=${project.build.sourceEncoding} -Xmx512m
</argLine>
<forkMode>always</forkMode>
<parallel>classes</parallel>
<includes>
<include>**/*.class</include>
</includes>
<excludes>
<exclude>**/*.IntegrationTest.java</exclude>
</excludes>
</configuration>
</plugin>
<!-- INTEGRATION tests that are run with "mvn clean verify" -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${version.surefire}</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>${version.surefire}</version>
</dependency>
</dependencies>
<configuration>
<forkMode>pertest</forkMode>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<argLine>${jacoco.argLine.it}
-Dfile.encoding=${project.build.sourceEncoding} -Xmx512m
</argLine>
<includes>
<include>**/*.class</include>
</includes>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<phase>verify</phase>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
测试似乎重复并且花费了这么长时间是否有原因?