java - 使用 'mvn clean test' 命令时 MVN TestNG 报告位置更改

标签 java maven selenium testng

这是我的surefire-plugin pom.xml 代码

<build>
    <plugins>
     <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M2</version>
            <configuration>
                <suiteXmlFiles>
                   <!-- <outputDirectory>${basedir}/target/new</outputDirectory>  -->
                    <suiteXmlFile>/home/ghost/automation/try/apps/testng.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
    </plugins>
</build>

当我使用mvn clean test运行此报告时,报告正在保存

{basepath}/target/surefire-reports

但我想将此位置更改为其他位置,所以我使用这两个代码

<reportsDirectory>./test-output/${timestamp}</reportsDirectory>
<outputDirectory>${basedir}/target/new</outputDirectory>

当我将其添加到我的 pom.xlm 时,我遇到了以下错误

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.927 s
[INFO] Finished at: 2018-12-12T11:58:10+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M2:test (default-test) on project apps: There are test failures.
[ERROR] 
[ERROR] Please refer to /home/ghost/automation/try/apps/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] There was an error in the forked process
[ERROR] Suite file /home/ghost/automation/try/apps/test-output is not a valid file
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process
[ERROR] Suite file /home/ghost/automation/try/apps/test-output is not a valid file
[ERROR]         at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:657)
[ERROR]         at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:283)
[ERROR]         at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:246)
[ERROR]         at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1159)
[ERROR]         at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1000)
[ERROR]         at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:846)
[ERROR]         at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
[ERROR]         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
[ERROR]         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
[ERROR]         at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
[ERROR]         at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR]         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
[ERROR]         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
[ERROR]         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
[ERROR]         at org.apache.maven.cli.MavenCli.execute(MavenCli.java:954)
[ERROR]         at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
[ERROR]         at org.apache.maven.cli.MavenCli.main(MavenCli.java:192)
[ERROR]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]         at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[ERROR] 
[ERROR] -> [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 about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

我读了这个问题并回答,从这里获取这两个代码

How to config TestNG test-output folder to be inside Maven target folder?

  • 这里的答案接受 GUI 模式,但是当我尝试 mvn clen test 时 终端不工作

Maven project does not generate testng results within test-output folder from selenium project

  • 这里提到默认的 test-ng 报告存储位置

最佳答案

您应该通过在项目中创建自定义文件夹来更改报告位置:

第 1 步:在项目的根位置创建名为“Reports -> Module Name(子文件夹)”的新文件夹

第 2 步:更改配置属性:

<reportsDirectory>Reports/Module Name</reportsDirectory>

关于java - 使用 'mvn clean test' 命令时 MVN TestNG 报告位置更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53737453/

相关文章:

python - 无法使用 Selenium、Anaconda3、Python 3.6 查找元素

java - java中vlcj播放视频失败

java - Spring MVC Controller 中的授权方法

java - HTTPEntity 给出空值

maven - 物理更改 Maven pom.xml <properties> 值

eclipse - 无法在 Eclipse 中加载 Maven 项目中的 Widgetsets

java - 如何读取单击多个相同的 href 以使用 css 使用 findby 元素获取值

java - 使用 commons-fileupload 时出现 NoClassDefFoundError

maven - 如何将Cobertura插件应用于所有项目或所有子项目

java - 在 Selenium Webdriver 出现 Element Not Visible Exception 后继续运行后续步骤