[英]Selenium tests Jacoco project coverage
我正在运行我的 selenium 项目模块,它不是主项目的一部分,我使用 Jacoco maven 插件和 surefire 插件运行 selenium 测试,Jacoco 只提供了 selenium 项目的代码覆盖率(exec 文件),而不是整个项目......我需要如何配置我的 Jacoco 和 Surefire 才能获得外部/整个项目的覆盖??
It is not true that you can not measure code coverage of your selenium tests.您无法衡量 selenium 测试的代码覆盖率是不正确的。 Take a look at JaCoCo as a tool: https://www.eclemma.org/jacoco/ It can measure the code coverage of: unit, integration, GUI tests and to combine it in one aggregated report.
看看 JaCoCo 作为一个工具: https ://www.eclemma.org/jacoco/ 它可以测量:单元、集成、GUI 测试的代码覆盖率,并将其组合在一个聚合报告中。
I'm not sure if I do not understand your question correctly… But if I understand it correctly, you want to see the code coverage for Selenium Tests on the productive code ?我不确定我是否没有正确理解您的问题……但是如果我理解正确,您想在生产代码上查看 Selenium 测试的代码覆盖率吗?
That is simply impossible!那简直是不可能的! Selenium helps you test the web application.
Selenium 可帮助您测试 Web 应用程序。 Your code is not being tested with Selenium, but just the web pages resulting from the process of your application.
您的代码没有使用 Selenium 进行测试,而只是测试了您的应用程序进程产生的网页。
You need to configure a jacoco java agent (tcpserver) in the running project to be tested & a jacococlient (jacococli.jar) to listen to the results.需要在运行的待测项目中配置一个jacoco java agent(tcpserver)&一个jacococlient(jacococli.jar)来监听结果。
Example:例子:
java -javaagent:path/to/your/jacocoagent.jar=address=*,port=36320,destfile=jacoco-it.exec,output=tcpserver -jar target/yourApplication.jar
Run end-to-end integration tests.运行端到端集成测试。
Dump the results:转储结果:
java -jar path/to/your/jacococli.jar dump --address localhost --port 36320 --destfile target/jacoco-it.exec
sleep 5
java -jar path/to/your/jacococli.jar report target/jacoco-it.exec --classfiles target/classes --sourcefiles src/main/java/ --html target/jacoco-report
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.