[英]Maven - separate integration tests from unit tests
Is it possible to isolate integration tests from unit tests within same module? 是否可以将集成测试与同一模块内的单元测试隔离开来?
I created simple pom: 我创建了简单的pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>prj</artifactId>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/integration/**/*.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>integration</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/integration/**/*.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
however with mvn -Pintegration test it doesn't invoke anything. 但是使用mvn -Pintegration测试它不会调用任何东西。 If I comment out excludes section in main build - then it starts to execute tests, but without profile as well.
如果我注释掉在主构建排除部分-然后它开始执行测试,但没有配置文件也是如此。
instead of: 代替:
<exclude>*/integration/**/*.java</exclude>
try: 尝试:
<include>*/unit/**.java</include>
then in the integration profile do 然后在集成配置文件中
<includes>
<exclude>**/unit/**/*.java</exclude>
<include>**/integration/**/*.java</include>
</includes>
you may have to play with getting the includes/excludes exactly right, but that's the general idea. 你可能不得不玩完全包含/排除,但这是一般的想法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.