首页 文章

Maven可以这样做吗?运行selenium test,生成报告,然后执行jar文件

提问于
浏览
0

目前我有一个selenium测试项目,我正在尝试自动化这个过程:1 . 运行selenium测试2.生成一个报告(surefire?)3 . 并做一些java代码执行(jar)

可以通过在maven中配置它们来实现吗?

我是maven的新手,不确定maven是否可以胜任这项工作?

1 回答

  • 1

    是的,maven会这样做 . 你需要做的就是:

    1.  Run tests in the "test" phase of the Maven lifecycle.
    2.  Generate a report.  If you are using Surefire with TestNG, in that case 
        TestNG automatically generates the report once you trigger its tests from
        the "test" phase.  If you need to post-process generate a report, then 
        you can create a "maven exec" task and bind it to the "verify" phase of
        the lifecycle.  One thing I do sometimes is generate HTML reports using a
        XSLT transformation using the xml-maven-plugin, triggered in the verify
        phase.
    3.  I believe the 'package' phase will generally .jar your code up into a jar.  
        You can change that configuration to do what you need it to though. 
    4.  Then, finally, create a "maven exec" task to run the .jar file at the end. 
        I think you could bind that to the "deploy" phase of the lifecycle.
    

    然后,为了执行整个生命周期,它是这样的:

    mvn clean compile test-compile test verify package deploy
    

相关问题