我在嵌入式服务器上为自己的集成测试运行maven war项目没有任何问题,但现在我需要运行多个战争并从另一个项目进行测试.
我想设置以下方案......
我在我的本地工作区中有两个Maven war项目,名为War1和War2.我想有一个第3个Maven项目WarIntegration,它只包含集成测试并执行以下操作:
这可能吗?什么插件设置将实现这一目标?WarIntergration应该是什么类型的项目(包装)?War1和War2应该是WarIntegration或依赖项中的模块吗?是否所有配置都可以用于WarIntegration项目,还是必须分布在项目中?
这类似于这个问题,除了我们必须使用由项目启动和停止的嵌入式服务器(可能在我们运行验证时),我们需要一个单独的项目进行集成测试: 我有一个多模块Maven 2 POM,两个WAR,如何配置它以在运行测试之前部署两个战争?
integration-testing maven embedded-server maven-failsafe-plugin
我在这个版本的Java上使用Maven 3.2.3
davea$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
Run Code Online (Sandbox Code Playgroud)
我跑的时候
mvn clean install
Run Code Online (Sandbox Code Playgroud)
我在集成测试中遇到如下错误...
testFindSampleUsersByCodeAscByDefault(org.mainco.subco.user.service.SampleUserService2IT) Time elapsed: 2.204 sec <<< ERROR!
java.lang.VerifyError: Expecting a stackmap frame at branch target 57
Exception Details:
Location:
org/mainco/subco/user/service/SampleUserServiceImpl$ValueComparator.compare(Lorg/mainco/subco/user/domain/User;Lorg/mainco/subco/user/domain/User;)I @10: ifnull
Reason:
Expected stackmap frame at this location.
Bytecode:
0x0000000: 2ab4 001b 2bb9 002e 0200 c600 2f2a b400
0x0000010: 1b2b b900 2e02 00c0 0030 b600 34c6 001c
0x0000020: 2ab4 001b 2bb9 002e 0200 c000 30b6 0034
0x0000030: b600 39b6 003e a700 0512 404e 2ab4 001b
0x0000040: 2cb9 002e …Run Code Online (Sandbox Code Playgroud) verifyerror java-8 maven-failsafe-plugin maven-compiler-plugin
我必须把我的集成测试下src/test用我的单元测试的休息,只是一个模式区别开来,例如*Integr*Test,*ITTest或者它们可以在src/it(如开发Maven插件和使用时的情况maven-invoker-plugin)?
我问这个是因为,对我来说,如果单元和集成测试都在同一个地方,它看起来不够干净(即使它们是通过Maven配置文件控制的).
我的目录结构如下:
src/integrationTest/javasrc/test/javasrc/main/java我试图通过故障保护来进行集成测试,但是没有按照我想要的方式进行。
我已经试过了:
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<testSourceDirectory>src/integrationTest/java</testSourceDirectory>
<testClassesDirectory>${project.build.directory}/it-classes</testClassesDirectory>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
和这个:
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>src/integrationTest/**/*.java</include>
</includes>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
无济于事 故障安全找不到运行的测试。
我已经能够使用build-helper-maven插件添加一个test-source目录,然后使用failsafe运行测试。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>add-integration-test-source-as-test-sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/integrationTest/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但是,现在的问题是,surefire现在也将测试作为单元测试运行。当故障保险应该能够找到测试时,似乎也不必使用其他插件。我不希望不需要使用build-helper maven插件并配置surefire来排除该路径。
我究竟做错了什么?
这让我疯了.Maven故障安全插件不会在我的项目上运行.如果我mvn verify只运行surefire运行.如果我键入mvn failsafe:verify它失败,并出现以下错误:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Simulation Experiment Server 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-failsafe-plugin:2.11:verify (default-cli) @ experiment-server ---
[INFO] Failsafe report directory: C:\IdeaProjects\experiment_server\target\failsafe-reports
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.551s
[INFO] Finished at: Fri Mar 30 11:24:58 GMT-06:00 2012
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.11:verify (default-cli) on project experiment-server: C:\IdeaProjects\experiment_server\target\failsafe-reports\failsafe-summary.xml (The system cannot find the path specified) -> …Run Code Online (Sandbox Code Playgroud) 我为JUnit编写了一个简单的RunListener,它可以很好地与Maven一起使用.我可以通过maven-failsafe-plugin注册它
<properties>
<property>
<name>listener</name>
<value>com.asml.lcp.middleware.common.jboss.test.tps.TestDocumentationListener</value>
</property>
</properties>
Run Code Online (Sandbox Code Playgroud)
并从监听器中查看正确的输出.
现在我想在Eclipse中注册相同的RunListener,以便在运行测试时看到相同的输出.
这可能吗?出于测试目的并保持一致,最好具有相同的输出.
我有一些与故障安全maven插件一起运行的集成测试(使用Selenium).Failsafe仅生成XML报告文件.
1)我想生成HTML报告
2)我想在Jenkins中有一个关于html报告的链接
对于1)我安装了"maven-surefire-report-plugin"来使用failafe-report-only目标.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.13</version>
<executions>
<execution>
<phase>post-integration-test</phase>
<goals>
<goal>failsafe-report-only</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但在标准输出中,似乎没有生成任何内容:
[INFO]
[INFO] >>> maven-surefire-report-plugin:2.13:failsafe-report-only (default) @ BaseContrats >>>
[INFO]
[INFO] <<< maven-surefire-report-plugin:2.13:failsafe-report-only (default) @ BaseContrats <<<
[INFO]
[INFO] --- maven-surefire-report-plugin:2.13:failsafe-report-only (default) @ BaseContrats ---
Run Code Online (Sandbox Code Playgroud)
在我的failsafe-reports目录中,我只有XML报告文件,但没有HTML报告文件.
它是为故障安全生成html报告的好插件吗?
对于2),我安装了Jenkins插件"Selenium HTML报告",并添加了帖子构建操作"Publish Selenium HTML report",并为"Selenium tests results location"参数配置了"target/failsafe-reports"值,但没有在Jenkins界面中显示(当然因为我的html报告文件没有生成...).
这两点可以帮助我吗?
我在配置forkCount中设置为零maven-failsafe-plugin,以便mvnDebug在调试时可以在测试中轻松使用和设置断点。
这会导致警告:
参数 forkCount 不应为 0,不分叉 JVM 进行测试会降低测试准确性,请确保 <forkCount> >= 1。
这是为什么?不分叉对准确性有什么影响?
我目前正在使用 Maven Failsafe 插件来分叉执行测试(在单独的 JVM 中并行运行多个测试)。
我根据机器的核心数量手动设置forkCount变量,但我希望 Maven 自动确定该变量,这样我最终可以得到如下结果:
<forkCount>${system.numCores}</forkCount>
Run Code Online (Sandbox Code Playgroud)
这可能吗?
我想访问存储在 jar 文件中的实现版本等信息。这似乎工作得很好,在任何技术中,但总是基于类加载器。
如果我想在我的 maven 环境中测试,当然我不能使用 surefire 插件,因为这是在 jar 中打包之前。因此我必须使用故障安全插件。
但是这两种技术都不起作用,很可能是因为一些关于类加载器的黑魔法。
获取实现版本的最简单方法就是
this.getClass().getPackage().getImplementationVersion()
Run Code Online (Sandbox Code Playgroud)
它从META-INF/MANIFEST.MF看起来像的罐子里读取
Name: eu/simuline/octave/
Extension-name: eu.simuline.octave
Specification-Version: 0.7
Implementation-Version: 0.7-SNAPSHOT
Run Code Online (Sandbox Code Playgroud)
也许不需要扩展,需要的是部分名称,它以一种明显的方式从包名称派生出来(尾部斜杠似乎很重要;-))。但如前所述,这仅适用于生产环境,不适用于带有故障安全插件的测试。然后java代码返回0.7-SNAPSHOT,否则它只是返回null,这意味着根据api文档,版本未知......好吧。
我该怎么做才能在 maven 测试中包含元信息???