Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/348.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Maven能做到吗?运行selenium测试,生成报告,然后执行一个jar文件_Java_Maven_Selenium - Fatal编程技术网

Java Maven能做到吗?运行selenium测试,生成报告,然后执行一个jar文件

Java Maven能做到吗?运行selenium测试,生成报告,然后执行一个jar文件,java,maven,selenium,Java,Maven,Selenium,目前我有一个selenium测试项目,我正在尝试自动化此过程: 1.运行selenium测试 2.生成报告(surefire?) 3.并执行一些java代码执行(jar) 可以通过在maven中配置它们来实现这一点吗 我是马文的新手,不确定马文是否能胜任这项工作 是的,马文会这么做。您需要做的就是: 1. Run tests in the "test" phase of the Maven lifecycle. 2. Generate a report. If you are using

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

可以通过在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

对从这里开始:关于阶段的一些调整:
package
阶段用于将各种资源捆绑到一个工件上,例如一个JAR。
install
阶段将把这个JAR复制到本地存储库,
deploy
将把它上传到远程存储库。您不必提及所有阶段,因此当您调用
mvn clean deploy
时,效果将是相同的。但是,Maven的第一步很容易做到:第三步在谈到构建生命周期时有点奇怪。可以这样做,我会选择
集成测试
验证
阶段进行绑定。谢谢,还有一个问题,我可以只在步骤1中运行特定类吗?如果我没有将测试类放在测试文件夹中,我还可以运行它们吗?不,测试类必须在测试文件夹中。通过将测试类位置配置为“main”目录下,您可以覆盖“标准目录布局”。不过那是个坏主意。我想不出为什么测试类需要在主jar中。