【发布时间】:2012-09-15 17:19:02
【问题描述】:
我正在使用 maven 运行我在 TestNG 套件中的集成测试。 在eclipse下运行套件时-我的测试套件运行成功。 当运行“mvn verify”来运行我的集成测试时,我看到故障安全插件配置调试打印,包括 suite.xml 文件和我编译的类的正确路径,但它不执行我的测试(构建过程成功完成)。
我尝试运行相同的 pom 配置,但使用的是 surefire 插件而不是故障安全插件,并且我的测试成功执行。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12.3</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/MyTestNgSuiteFile.xml</suiteXmlFile>
</suiteXmlFiles>
<argLine>-Xmx1024m</argLine>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<phase>verify</phase>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
这是相关的控制台输出:
[调试] 排除: org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1 [DEBUG] 排除:junit:junit:jar:3.8.1 [DEBUG] 排除: org.apache.maven:maven-core:jar:2.0.9 [DEBUG] 排除: org.apache.maven:maven-plugin-parameter-documenter:jar:2.0.9 [DEBUG]
排除:org.apache.maven:maven-repository-metadata:jar:2.0.9 [DEBUG] 排除:org.apache.maven:maven-error-diagnostics:jar:2.0.9 [DEBUG]
排除:org.apache.maven:maven-plugin-descriptor:jar:2.0.9 [DEBUG]
排除:org.apache.maven:maven-monitor:jar:2.0.9 [DEBUG] 排除: classworlds:classworlds:jar:1.1 [DEBUG] 排除: org.apache.maven:maven-toolchain:jar:2.0.9 [调试] 配置 mojo org.apache.maven.plugins:maven-failsafe-plugin:2.12.3:integration-test 来自插件领域 ClassRealm[插件>org.apache.maven.plugins:maven-failsafe-plugin:2.12.3, 父:sun.misc.Launcher$AppClassLoader@121ab80] [DEBUG] 配置 魔力 'org.apache.maven.plugins:maven-failsafe-plugin:2.12.3:integration-test' 使用基本配置器 --> [调试] (s) argLine = -Xmx1024m [调试] (s) basedir = PathToMyDir\MyProject [DEBUG] (s) childDelegation = false [DEBUG] (s) classesDirectory = PathToMyDir\MyProject\target\classes [DEBUG] (s) disableXmlReport = false [DEBUG] (s) enableAssertions = true [DEBUG] (s) forkMode = 一次 [DEBUG] (s) junitArtifactName = junit:junit [DEBUG] (s) localRepository = id:本地 网址:file:///..../.m2/repository/ 布局:无[DEBUG] (f) parallelMavenExecution = false [DEBUG] (s) perCoreThreadCount = true [DEBUG] (s) pluginArtifactMap = {org.apache.maven.plugins:maven-failsafe-plugin=org.apache.maven.plugins:maven-failsafe-plugin:maven-plugin:2.12.3:, org.apache.maven.surefire:surefire-booter=org.apache.maven.surefire:surefire-booter:jar:2.12.3:compile, org.apache.maven.surefire:surefire-api=org.apache.maven.surefire:surefire-api:jar:2.12.3:compile, org.apache.maven.surefire:maven-surefire-common=org.apache.maven.surefire:maven-surefire-common:jar:2.12.3:compile, org.apache.commons:commons-lang3=org.apache.commons:commons-lang3:jar:3.1:compile, org.apache.maven.shared:maven-common-artifact-filters=org.apache.maven.shared:maven-common-artifact-filters:jar:1.3:compile, org.codehaus.plexus:plexus-utils=org.codehaus.plexus:plexus-utils:jar:3.0.5:compile, org.apache.maven.reporting:maven-reporting-api=org.apache.maven.reporting:maven-reporting-api:jar:2.0.9:compile, org.apache.maven.plugin-tools:maven-plugin-注释=org.apache.maven.plugin-tools:maven-plugin-annotations:jar:3.1:compile} [调试] (f) pluginDescriptor = 组件描述符:角色: 'org.apache.maven.plugin.Mojo',实现: 'org.apache.maven.plugin.failsafe.HelpMojo',角色提示: 'org.apache.maven.plugins:maven-failsafe-plugin:2.12.3:help' 角色: 'org.apache.maven.plugin.Mojo',实现: 'org.apache.maven.plugin.failsafe.IntegrationTestMojo',角色提示: 'org.apache.maven.plugins:maven-failsafe-plugin:2.12.3:integration-test' 角色:'org.apache.maven.plugin.Mojo',实现: 'org.apache.maven.plugin.failsafe.VerifyMojo',角色提示: 'org.apache.maven.plugins:maven-failsafe-plugin:2.12.3:verify' --- [DEBUG] (s) printSummary = true [DEBUG] (s) projectArtifactMap = {All Artifacts Here} [DEBUG] (s) redirectTestOutputToFile = false [DEBUG] (s) remoteRepositories = [ id: central 网址:http://repo1.maven.org/maven2 布局:默认快照:[启用 => 假,更新 => 每日] 发布:[启用 => 真, update => never] ] [DEBUG] (s) reportFormat = brief [DEBUG] (s) 报告目录 = PathToMyDir\MyProject\target\failsafe-reports [DEBUG] (s) runOrder = 文件系统 [DEBUG] (s) skip = false [DEBUG] (s) skipTests = false [DEBUG] (s) suiteXmlFiles = [PathToMyDir\MyProject\src\test\resources\MyTestNgSuiteFile.xml] [DEBUG] (s) 摘要文件 = PathToMyDir\MyProject\target\failsafe-reports\failsafe-summary.xml [DEBUG] (s) testClassesDirectory = PathToMyDir\MyProject\target\test-classes [DEBUG] (s) testNGArtifactName = org.testng:testng [DEBUG] (s) testSourceDirectory = PathToMyDir\MyProject\src\test\java [调试]
(s) trimStackTrace = true [DEBUG] (s) useFile = true [DEBUG] (s) useManifestOnlyJar = true [DEBUG] (s) useSystemClassLoader = true [DEBUG] (s) useUnlimitedThreads = false [DEBUG] (s) workingDirectory = PathToMyDir\MyProject [DEBUG] (s) project = MavenProject:MyParentProject:MyProject:0.0.1-SNAPSHOT @ PathToMyDir\MyProject\pom.xml [DEBUG] (s) session = org.apache.maven.execution.MavenSession@bffe59 [DEBUG] -- 结束 配置 -- [警告] 文件编码尚未设置,使用 平台编码 Cp1255,即构建依赖于平台! [信息] [INFO] --- maven-failsafe-plugin:2.12.3:verify(验证)@MyProject --- [调试] 配置 mojo org.apache.maven.plugins:maven-failsafe-plugin:2.12.3:verify from 插件领域 ClassRealm[插件>org.apache.maven.plugins:maven-failsafe-plugin:2.12.3, 父:sun.misc.Launcher$AppClassLoader@121ab80] [DEBUG] 配置 mojo 'org.apache.maven.plugins:maven-failsafe-plugin:2.12.3:verify' 使用基本配置器 --> [DEBUG] (s) basedir = PathToMyDir\MyProject [DEBUG] (s) reportsDirectory = PathToMyDir\MyProject\target\failsafe-reports [DEBUG] (s) 跳过 = 错误 [DEBUG] (f) 摘要文件 = PathToMyDir\MyProject\target\failsafe-reports\failsafe-summary.xml [DEBUG] (s) testClassesDirectory = PathToMyDir\MyProject\target\test-classes [DEBUG] (s) testFailureIgnore = false [DEBUG] -- 结束配置 -- [INFO] 故障安全报告目录: PathToMyDir\MyProject\target\failsafe-reports [警告] 文件编码 尚未设置,使用平台编码 Cp1255,即 build 是 平台相关!
看起来 "Forking command line: cmd.exe /X /C "C:\Program Files (x86)\Java\jdk1.7.0_04..." 命令丢失并且没有被执行。 我将不胜感激。
【问题讨论】:
-
“但它不运行我的测试”是什么意思?错误信息?此外,您是否正确配置了 maven-failsafe-plugin?
-
我没有看到任何错误,我的测试也没有执行。我只是将故障安全插件“验证”目标设置为 Maven“验证”周期。无论如何,当我明确执行“failsafe:verify”或“failsafe:integration-test”时也会发生这种情况
-
你能把你的完整pom贴出来吗。
-
在目标之上运行时能否发布控制台消息。
-
我已使用请求的信息编辑了我的原始帖子。
标签: maven integration-testing testng test-suite maven-failsafe-plugin