gpt4 book ai didi

Maven 自动跳过测试

转载 作者:行者123 更新时间:2023-11-28 19:39:29 26 4
gpt4 key购买 nike

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 Artifact 被正确复制到目标目录并跳过测试。 mvn verify -Dtest=TestCalculator 具有相同的结果。我正在使用 ArquillianTestNG 来执行实际测试,但我不确定这对这个问题是否重要。

编辑

在调试中运行将给出(相关部分)

[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{
//...
}

}

最佳答案

调试输出显示:

[DEBUG]   (s) skip = true

这不仅会跳过运行 测试,还会跳过编译 测试。如果您好奇的话,请检查父 POM(此 POM 直接引用,以及 Arquillian 引入的任何公司 POM 或 super POM)以查看此标志的设置位置。

修复是添加

<skip>false</skip>

到这个模块的surefire插件配置,或者添加

-Dmaven.test.skip=false

到你的命令行。

Reference

关于Maven 自动跳过测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17547931/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com