目前我有一个selenium测试项目,我正在尝试自动执行此过程: 1.进行硒测试 2.生成报告(surefire?) 3.并做一些java代码执行(jar)
是否可以通过在maven中配置它们来实现此目的?
我是maven的新手,不确定maven是否可以胜任这项工作?
答案 0 :(得分: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