简体   繁体   English

Selenium 测试 Jacoco 项目覆盖率

[英]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.

相关问题 JaCoCo与多模块Maven项目-仅记录模块拥有的测试的覆盖率 - JaCoCo with multi-module Maven project - Only record coverage by module owned tests 使用 Jacoco 进行 Cucumber 测试的代码覆盖率 - Code Coverage for Cucumber Tests using Jacoco Jacoco:查找外部测试的代码覆盖率 - Jacoco: Find code coverage for external tests 测量驻留在单独项目中的硒测试的代码覆盖率 - Measuring code coverage for selenium tests that reside in separate project 多模块项目的声纳 maven jacoco 代码覆盖率 - Sonar maven jacoco code coverage for Multimodule project Jacoco 报告在 intellij 上运行的 apache 项目的覆盖率为 0% - Jacoco report 0% coverage on apache project run on intellij NetBeans单独模块中集成测试的jacoco代码覆盖率 - jacoco code coverage of integration tests in a separate module in Netbeans 使用 Jacoco 对使用 Powermock 编写的测试类进行单元测试 - Unit tests coverage using Jacoco for test classes written using Powermock 当代码和单元测试在不同模块中时,Quarkus Jacoco 覆盖率不起作用 - Quarkus Jacoco coverage not working when code and unit tests are in different modules 使用Sonar和maven进行Jacoco代码覆盖,以便在单独的模块中进行集成测试 - Jacoco code coverage with Sonar and maven for integration tests in separate module
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM