我面临一个问题,即未选择测试/资源,而是挑选jar的主/资源
场景如下:Myproject src/test/resources ---具有config.xml w,abc.jar应该需要它,这是Myproject中的依赖.
当为Myproject运行测试用例时,它加载abc.jar的config.xml而不是Myproject test/resources. - 我需要知道maven选择资源的顺序. - 或者我正在努力尝试是不可能的.
谢谢.
我正在尝试使用子模块来测试和生成报告,但是遇到了一些问题.
我有以下项目结构:
parent
|-test1
|-test2
Run Code Online (Sandbox Code Playgroud)
和pom.xml parent看起来像这样:
<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>
<groupId>parent</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>test1</module>
<module>test2</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.16</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<configuration>
<aggregate>true</aggregate>
<reportsDirectories>
<reportsDirectory>${basedir}/target/surefire-reports</reportsDirectory>
</reportsDirectories>
</configuration>
<reportSets>
<reportSet>
<inherited>false</inherited>
<reports>
<report>report-only</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
Run Code Online (Sandbox Code Playgroud)
我mvn clean install site用来构建项目,运行测试并生成一个站点(使用maven站点插件,后者又使用maven surefire报告插件生成测试报告).
问题是在执行子模块的pom.xml之前,父pom.xml与所有阶段(清理,安装和站点)一起执行,因此没有来自test1和test2聚合的测试报告parent. …
我正在尝试使用Intellij IDEA与Maven构建Java插件,直到我遇到错误:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.803 s
[INFO] Finished at: 2015-06-16T16:34:55-10:00
[INFO] Final Memory: 17M/216M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project mc-hyperchat: Error occurred in starting fork, check output in log -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information …Run Code Online (Sandbox Code Playgroud) 我们正在使用JUnit - Selenium进行网络测试.我们使用Maven启动它们并构建一个万无一失的报告.
测试套件非常大,运行需要一段时间,有时单个测试失败,因为浏览器无法启动.我希望能够使用maven运行SINGLE测试,因此我重新测试失败的测试并更新报告.
我可以用来mvn test -Dtest=TESTCLASSNAME在一个测试类中运行所有测试,但这还不够好,因为在我们最复杂的测试类中运行所有测试大约需要10分钟,而且其他测试很可能会失败(因为浏览器)不会开始)这会弄乱我的报告.
我知道我可以从Eclipse运行一个测试,但这不是我想要的.
对此的任何帮助都会非常有用
当在Windows上的Maven中运行我的单元测试时,我得到一个OutOfMemory异常.我尝试将-XX:-HeapDumpOnOutOfMemoryError选项添加到surefire argLine,但是没有生成转储文件.我也尝试向MAVEN_OPTS添加相同的东西,但仍然没有,我只是得到一个OutOfMemory异常并且该过程挂起,直到我手动杀死它.
我的pom如下:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>false</testFailureIgnore>
<argLine>-Xms512m -Xmx512m -XX:PermSize=256m -XX:-HeapDumpOnOutOfMemoryError</argLine>
<forkMode>once</forkMode>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
MAVEN_OPTS:
set MAVEN_OPTS=-XX:-HeapDumpOnOutOfMemoryError
Run Code Online (Sandbox Code Playgroud)
你知道为什么没有生成转储文件吗?
我想只运行我的单元测试的一个子集,由特定的测试定义@Category.
所以我读了几个SO问题,比如这个(这正是我要找的),还有这个问题.
我的问题的解决方案似乎是由ClasspathSuite项目提供的.所以我开始编写定义我的测试类别的接口NewTest和OldTest接口.然后,我创建了AllTests套件:
@RunWith(ClasspathSuite.class)
public class AllTests { }
Run Code Online (Sandbox Code Playgroud)
之后,我创建了一个AllNewTests套件:
@RunWith(Categories.class)
@IncludeCategory(NewTest.class)
@SuiteClasses( { AllTests.class })
public class AllNewTests { }
Run Code Online (Sandbox Code Playgroud)
最后,我创建了两个JUnit类,每个类别一个:
@Category(NewTest.class)
public class SomeNewTests {
// some tests...
}
@Category(OldTest.class)
public class SomeOldTests {
// some tests...
}
Run Code Online (Sandbox Code Playgroud)
现在,如果我运行AllTests,Eclipse会启动我项目的所有测试,而Maven会因为没有找到测试而失败:
mvn test -Dtest=AllTests
...
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running my.company.AllTests
Tests run: 0, Failures: 0, Errors: 0, Skipped: …Run Code Online (Sandbox Code Playgroud) 我需要使用surefire v2.12,但每次运行该版本时都会获得附加的堆栈跟踪.如果我运行v2.10我没有收到错误.我需要这个版本,所以我可以用@Category注释我的测试类,并将它们标记为UnitTests或IntegrationTests.这是我的命令:mvn test -Dsurefire.version = 2.12 -X
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project PROJECT: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test failed: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null: ExceptionInInitializerError: Unexpected ClassNotFoundException looking up class 'org.apache.maven.cli.MavenCli' -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project ASPEN: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test failed: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at … 请原谅这个新问题 - 我的概念模型仍然很不完整......
我正在尝试使用 Maven 和 Surefire 从命令行重新执行 TestNG 测试。我的命令行如下所示:
D:\workspaces\workspace01\aptest>mvn clean install surefire:test -Dtests=myTestNGSuite test
Run Code Online (Sandbox Code Playgroud)
显然我没有得到它,因为我最终得到的输出包括:
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ aptest ---
[INFO] Skipping execution of surefire because it has already been run for this configuration
Run Code Online (Sandbox Code Playgroud)
如何清除配置以便可以从命令行重新运行我的 TestNG 套件?有没有更好的方法从命令行运行 TestNG 套件?
蒂亚,-->亚伦
我有一个包含各种子模块的父pom项目.我想获得单元测试结果的报告,但是使用surfire插件,我得到每个模块的独立结果.
我的意思是,如果我执行:
mvn surefire-report:report
Run Code Online (Sandbox Code Playgroud)
从父pom所在的父目录,它为每个子项目创建一个surefire-report.html,但我想要的只是一个html与所有子项目的结果.
有没有办法自动实现这一目标?使用surefire或其他一些插件.
Maven Surefire为每个失败的测试记录标准输出和错误输出,稍后可以在surefire-reports目录中生成的文件中找到这些输出。然而,没有错误通过的测试的输出被丢弃。是否可以设置surefire来记录成功通过的测试的stdout/stderr?