{"id":15779661,"url":"https://github.com/aldaviva/cobertura-maven-plugin","last_synced_at":"2025-03-31T15:54:13.289Z","repository":{"id":70211298,"uuid":"82180672","full_name":"Aldaviva/cobertura-maven-plugin","owner":"Aldaviva","description":"Another Maven plugin to measure Java code coverage using Cobertura, this time with build-failing thresholds and tests that only run once.","archived":false,"fork":false,"pushed_at":"2017-04-09T14:58:47.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T07:08:32.487Z","etag":null,"topics":["cobertura","coverage","maven-plugin"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Aldaviva.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://paypal.me/aldaviva"]}},"created_at":"2017-02-16T12:57:06.000Z","updated_at":"2021-01-17T21:41:17.000Z","dependencies_parsed_at":"2023-03-02T11:45:15.210Z","dependency_job_id":null,"html_url":"https://github.com/Aldaviva/cobertura-maven-plugin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aldaviva%2Fcobertura-maven-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aldaviva%2Fcobertura-maven-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aldaviva%2Fcobertura-maven-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aldaviva%2Fcobertura-maven-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aldaviva","download_url":"https://codeload.github.com/Aldaviva/cobertura-maven-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246492199,"owners_count":20786325,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cobertura","coverage","maven-plugin"],"created_at":"2024-10-04T18:20:53.595Z","updated_at":"2025-03-31T15:54:13.270Z","avatar_url":"https://github.com/Aldaviva.png","language":"Java","funding_links":["https://paypal.me/aldaviva"],"categories":[],"sub_categories":[],"readme":"cobertura-maven-plugin\n===\n\nThis is a [Maven](https://maven.apache.org/) plugin that lets you measure code coverage of your tests using \n[Cobertura](https://cobertura.github.io/cobertura/). It's a different project than the official \n[`org.codehaus.mojo:cobertura-maven-plugin`](http://www.mojohaus.org/cobertura-maven-plugin/).\n\n## Features\n\n- Tests run once, not twice\n- Minimum thresholds for line or branch coverage percentage that will allow the build to succeed\n- Exclude certain files from coverage threshold checks\n- Cobertura is compatible with testing utilities that modify bytecode, like the fantastic \n[PowerMock](https://powermock.github.io/), because classes are instrumented on disk before tests start, not during \nruntime with a JVM agent like the otherwise-fantastic [JaCoCo](http://www.eclemma.org/jacoco/).\n\n## Usage\n\n### Installation\n\nAdd these snippets to your POM.\n\n```xml\n\u003cproject\u003e\n    \u003cdependencies\u003e\n        \u003c!-- This allows tests to update coverage counters when instructions are executed --\u003e\n        \u003cdependency\u003e\n            \u003cgroupId\u003enet.sourceforge.cobertura\u003c/groupId\u003e\n            \u003cartifactId\u003ecobertura\u003c/artifactId\u003e\n            \u003cversion\u003e2.1.1\u003c/version\u003e\n            \u003cscope\u003etest\u003c/scope\u003e\n        \u003c/dependency\u003e\n    \u003c/dependencies\u003e\n    \n    \u003cbuild\u003e\n        \u003cplugins\u003e\n            \u003cplugin\u003e\n                \u003cgroupId\u003ecom.aldaviva.coverage\u003c/groupId\u003e\n                \u003cartifactId\u003ecobertura-maven-plugin\u003c/artifactId\u003e\n                \u003cversion\u003e0.0.1-SNAPSHOT\u003c/version\u003e\n                \u003cconfiguration\u003e\n                    \u003cexclusions\u003e\n                        \u003c!-- Exclude any files you don't want counting against your coverage thresholds. --\u003e\n                             Ant path syntax:\n                               ** = multiple directories\n                               *  = single directory or multiple characters\n                               ?  = single character\n                        --\u003e\n                        \u003cparam\u003e**/*Exception.class\u003c/param\u003e\n                        \u003cparam\u003ecom/mycompany/myprogram/Untestable.class\u003c/param\u003e\n                    \u003c/exclusions\u003e\n                    \n                    \u003c!-- Specify minimum coverage thresholds for lines of code or branching statements as a floating-point number between 0.0 (no coverage) and 1.0 (full coverage) --\u003e\n                    \u003cminLineCoveredRatio\u003e0.80\u003c/minLineCoveredRatio\u003e\n                    \u003cminBranchCoveredRatio\u003e0.80\u003c/minBranchCoveredRatio\u003e\n                \u003c/configuration\u003e\n\n                \u003cexecutions\u003e\n                    \u003c!-- Add instrumentation instructions to bytecode before tests run --\u003e\n                    \u003cexecution\u003e\n                        \u003cid\u003einstrument\u003c/id\u003e\n                        \u003cgoals\u003e\n                            \u003cgoal\u003einstrument\u003c/goal\u003e\n                        \u003c/goals\u003e\n                        \u003cphase\u003eprocess-test-classes\u003c/phase\u003e\n                    \u003c/execution\u003e\n\n                    \u003c!-- Restore uninstrumented class files after tests are done, and fail the build if coverage thresholds were not met --\u003e\n                    \u003cexecution\u003e\n                        \u003cid\u003echeck\u003c/id\u003e\n                        \u003cgoals\u003e\n                            \u003cgoal\u003echeck\u003c/goal\u003e\n                        \u003c/goals\u003e\n                        \u003cphase\u003eprepare-package\u003c/phase\u003e\n                    \u003c/execution\u003e\n                \u003c/executions\u003e\n            \u003c/plugin\u003e\n        \u003c/plugins\u003e\n    \u003c/build\u003e\n\u003c/project\u003e\n```\n\n### Execution example\n```text\n$ mvn package\n[INFO] Scanning for projects...\n[INFO]                                                                         \n[INFO] ------------------------------------------------------------------------\n[INFO] Building Sample project 0.0.1-SNAPSHOT\n[INFO] ------------------------------------------------------------------------\n[INFO] \n[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ sample-project ---\n[INFO] Deleting C:\\Users\\Ben\\Documents\\Projects\\sample-project\\target\n[INFO] \n[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ sample-project ---\n[INFO] Using 'UTF-8' encoding to copy filtered resources.\n[INFO] Copying 0 resource\n[INFO] \n[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ sample-project ---\n[INFO] Changes detected - recompiling the module!\n[INFO] Compiling 2 source files to C:\\Users\\Ben\\Documents\\Projects\\sample-project\\target\\classes\n[INFO] \n[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ sample-project ---\n[INFO] Using 'UTF-8' encoding to copy filtered resources.\n[INFO] skip non existing resourceDirectory C:\\Users\\Ben\\Documents\\Projects\\sample-project\\src\\test\\resources\n[INFO] \n[INFO] --- maven-compiler-plugin:3.6.1:testCompile (default-testCompile) @ sample-project ---\n[INFO] Changes detected - recompiling the module!\n[INFO] Compiling 1 source file to C:\\Users\\Ben\\Documents\\Projects\\sample-project\\target\\test-classes\n[INFO] \n[INFO] --- cobertura-maven-plugin:0.0.1-SNAPSHOT:instrument (instrument) @ sample-project ---\n[INFO] Cobertura: Saved information on 1 classes.\n[INFO] \n[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ sample-project ---\n[INFO] Surefire report directory: C:\\Users\\Ben\\Documents\\Projects\\sample-project\\target\\surefire-reports\n\n-------------------------------------------------------\n T E S T S\n-------------------------------------------------------\nRunning com.aldaviva.coverage.MainTest\nConfiguring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@1963006a\nTests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.402 sec\n[INFO] Cobertura: Loaded information on 1 classes.\n[INFO] Cobertura: Saved information on 1 classes.\n\nResults :\n\nTests run: 1, Failures: 0, Errors: 0, Skipped: 0\n\n[INFO] \n[INFO] --- cobertura-maven-plugin:0.0.1-SNAPSHOT:check (check) @ sample-project ---\n[INFO] Cobertura: Loaded information on 1 classes.\n[INFO] Line coverage: 85.7% actual, 100.0% required.\n[INFO] Branch coverage: 50.0% actual, 100.0% required.\n[INFO] ------------------------------------------------------------------------\n[INFO] BUILD FAILURE\n[INFO] ------------------------------------------------------------------------\n[INFO] Total time: 3.410 s\n[INFO] Finished at: 2017-04-09T07:28:17-07:00\n[INFO] Final Memory: 19M/248M\n[INFO] ------------------------------------------------------------------------\n[ERROR] Failed to execute goal com.aldaviva.coverage:cobertura-maven-plugin:0.0.1-SNAPSHOT:check (check) on project sample-project: Coverage checks not met -\u003e [Help 1]\n[ERROR] \n[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.\n[ERROR] Re-run Maven using the -X switch to enable full debug logging.\n[ERROR] \n[ERROR] For more information about the errors and possible solutions, please read the following articles:\n[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException\n[INFO] Cobertura: Loaded information on 1 classes.\n[INFO] Cobertura: Saved information on 1 classes.\n```\n\nCobertura's data file will be saved as `cobertura.ser` in the `${project.baseDir}` directory, so your build machine can generate useful coverage reports.\n\n## Acknowledgements\n- [jacoco-maven-plugin](http://www.eclemma.org/jacoco/trunk/doc/maven.html) for showing me the light that build systems shouldn't have to run tests twice just to measure coverage.\n- [Michel Pawlak](http://www.pawlak.ch/)'s [qualinsight-mojo-cobertura](https://github.com/QualInsight/qualinsight-mojo-cobertura) plugin for the idea to backup, instrument, and restore the entire `classes` directory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faldaviva%2Fcobertura-maven-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faldaviva%2Fcobertura-maven-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faldaviva%2Fcobertura-maven-plugin/lists"}