为什么 Maven 默认会跳过我的所有测试?我有pom.xml
几个配置文件,我无法通过它们运行我的测试。我的个人资料之一看起来像
<profile>
<id>jsf-test</id>
<dependencies>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-arquillian-container-remote</artifactId>
<version>${jboss.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jsf.tests</groupId>
<artifactId>jsf-app</artifactId>
<version>${jsf-app.version}</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-jsf-app</id>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.jsf.tests</groupId>
<artifactId>jsf-app</artifactId>
<version>${jsf-app.version}</version>
<type>war</type>
<destFileName>jsfapp.war</destFileName>
<outputDirectory>target</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version>
<configuration>
<skipTests>false</skipTests> <!-- desperate trial -->
<properties>
<property>
<name>listener</name>
<value>${testng.listeners}</value>
</property>
</properties>
</configuration>
</plugin>
</plugins>
</build>
</profile>
如果我运行mvn verify -Pjsf-test
,则编译项目,将jsf-app
工件正确复制到目标目录并跳过测试。mvn verify -Dtest=TestCalculator
有相同的结果。我正在使用Arquillian
并TestNG
执行实际测试,但我不确定这对这个问题是否重要。
编辑
在调试中运行将给出(相关部分)
[DEBUG] (s) reportFormat = brief
[DEBUG] (s) reportsDirectory = /home/pmensik/Work/workspace/epp-test/cdi-arquillian- test/target/surefire-reports
[DEBUG] (f) reuseForks = true
[DEBUG] (s) runOrder = filesystem
[DEBUG] (s) skip = true
[DEBUG] (s) skipTests = false
[DEBUG] (s) systemPropertyVariables = {jsfPortlet=true}
[DEBUG] (s) testClassesDirectory = /home/pmensik/Work/workspace/epp-test/cdi-arquillian-test/target/test-classes
[DEBUG] (s) testFailureIgnore = false
[DEBUG] (s) testNGArtifactName = org.testng:testng
[DEBUG] (s) testSourceDirectory = /home/pmensik/Work/workspace/epp-test /cdi-arquillian-test/src/test/java
[DEBUG] (s) trimStackTrace = true
[DEBUG] (s) useFile = true
[DEBUG] (s) useManifestOnlyJar = true
[DEBUG] (s) useSystemClassLoader = true
[DEBUG] (s) useUnlimitedThreads = false
[DEBUG] (s) workingDirectory = /home/pmensik/Work/workspace/epp-test/cdi-arquillian-test
[DEBUG] (s) project = MavenProject: org.jboss.gatein.test:cdi-portlet-test:6.1-ER01 @ /home/pmensik/Work/workspace/epp-test/cdi-arquillian-test/pom.xml
[DEBUG] (s) session = org.apache.maven.execution.MavenSession@3c3483ec
[DEBUG] -- end configuration --
[INFO] Tests are skipped.
我最简单的测试看起来像这样
public class Test {
@Drone
protected WebDriver driver;
@Deployment(testable = false)
public static WebArchive createTestArchive() {
return ShrinkWrap.createFromZipFile(WebArchive.class, new File("target/CDIPortlet.war"));
}
@Test
public void testCase{
//...
}
}