New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce task for JaCoCo plugin for enforcing code coverage metrics #983
Merged
Merged
Changes from 32 commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
313367a
Basic support for enforcing Jacoco metrics
d7f3b7d
Add test cases for multiple report tasks
3f50fcd
Add test case for multiple rules
5c3a8ad
Break out method
c27a0b2
Expose configuration option for disabling rules
3f971f7
Rules can be checked even if all report formats are disabled
2c7be9f
Use strong typing for enums
530828f
Rename of method
493e282
Add some unit tests
317ec14
Renamed property
5b0f085
Set default values for fields as described in Jacoco docs
f8f3070
Renamed fields to better express intention
9b5ed0a
Rename field
358a6f9
Enhance samples and documentation
a73a193
Better IDE support for Closure parameters
6627b49
Bump up version number
8e6d20c
Use String data type instead of enum
70b0f0a
Align terminology with Jacoco configuration options
aed27f6
Apply input/output annotations
00b2cb3
Document default value for property
0dc8b31
Verify proper behavior of Ant task for unknown values
45674bd
Remove spaces
ebb4d11
Add multi-version coverage for check support
41dcf72
Reuse version number across all multi-version tests
0521afb
Add missing word
6c63ff9
Use constant for task paths
db94948
Extract dedicated task for verifying if coverage metrics are met
f024a94
Input annotation make sure that requires properties are not null
aa402c8
Reflect use of JacocoCheck task in documentation and sample
08882e9
Revert change
6b1f8d9
Use JacocoCheck in documentation
1eb517c
Reuse task logic for JacocoReport and JacocoCheck
8d06c8f
Fix indentation
699a622
Reuse logic
47feb94
Move logic into parent class
8097fdd
Task is not cacheable as it doesn't declare outputs
ff77afc
Ignore running tests on Java 9
1e31712
Report task should fail if any of the input file does not exist
a7a4592
Assign group and description for tasks
d900795
Use task name that better expresses intent
d832d0d
Change targeted release version
ec1b003
Fix task name in sample project
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
subprojects/docs/src/docs/dsl/org.gradle.testing.jacoco.tasks.JacocoCheck.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!-- | ||
~ Copyright 2016 the original author or authors. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<section> | ||
<section> | ||
<title>Properties</title> | ||
<table> | ||
<thead> | ||
<tr> | ||
<td>Name</td> | ||
<td>Default with <literal>jacoco</literal> plugin</td> | ||
</tr> | ||
</thead> | ||
<tr> | ||
<td>violationRules</td> | ||
<td/> | ||
</tr> | ||
</table> | ||
</section> | ||
<section> | ||
<title>Methods</title> | ||
<table> | ||
<thead> | ||
<tr> | ||
<td>Name</td> | ||
</tr> | ||
</thead> | ||
</table> | ||
</section> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
subprojects/docs/src/docs/dsl/org.gradle.testing.jacoco.tasks.JacocoReportBase.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<!-- | ||
~ Copyright 2016 the original author or authors. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<section> | ||
<section> | ||
<title>Properties</title> | ||
<table> | ||
<thead> | ||
<tr> | ||
<td>Name</td> | ||
<td>Default with <literal>jacoco</literal> plugin</td> | ||
</tr> | ||
</thead> | ||
<tr> | ||
<td>executionData</td> | ||
<td/> | ||
</tr> | ||
<tr> | ||
<td>sourceDirectories</td> | ||
<td/> | ||
</tr> | ||
<tr> | ||
<td>classDirectories</td> | ||
<td/> | ||
</tr> | ||
<tr> | ||
<td>additionalClassDirs</td> | ||
<td/> | ||
</tr> | ||
<tr> | ||
<td>additionalSourceDirs</td> | ||
<td/> | ||
</tr> | ||
</table> | ||
</section> | ||
<section> | ||
<title>Methods</title> | ||
<table> | ||
<thead> | ||
<tr> | ||
<td>Name</td> | ||
</tr> | ||
</thead> | ||
<tr> | ||
<td>executionData</td> | ||
</tr> | ||
</table> | ||
</section> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,32 @@ | |
</imageobject> | ||
</section> | ||
|
||
<section id="sec:jacoco_report_violation_rules"> | ||
<title>Enforcing code coverage metrics</title> | ||
<note> | ||
<para> | ||
This feature requires the use of JaCoCo version 0.6.3 or higher. | ||
</para> | ||
</note> | ||
<para> | ||
The <apilink class="org.gradle.testing.jacoco.tasks.JacocoCheck"/> task can be used to verify if code coverage | ||
metrics are met based on configured rules. Its API exposes two methods, | ||
<apilink class="org.gradle.testing.jacoco.tasks.JacocoCheck" method="violationRules(groovy.lang.Closure)"/> and | ||
<apilink class="org.gradle.testing.jacoco.tasks.JacocoCheck" method="violationRules(org.gradle.api.Action)"/>, | ||
the main entry point for configuring rules. | ||
Invoking any of those methods returns an instance of <apilink class="org.gradle.testing.jacoco.tasks.rules.JacocoViolationRulesContainer"/> providing | ||
extensive configuration options. The build fails if any of the configured rules are not met. JaCoCo only reports the first violated rule. | ||
</para> | ||
<para> | ||
Code coverage requirements can be specified for a project as a whole, for individual files, and for | ||
particular JaCoCo-specific types of coverage, e.g., lines covered or branches covered. The following example | ||
describes the syntax. | ||
</para> | ||
<sample id="configViolationRules" dir="testing/jacoco/quickstart" title="Configuring violation rules"> | ||
<sourcefile file="build.gradle" snippet="violation-rules-configuration"/> | ||
</sample> | ||
</section> | ||
|
||
<section id="sec:jacoco_specific_task_configuration"> | ||
<title>JaCoCo specific task configuration</title> | ||
<para>The JaCoCo plugin adds a | ||
|
@@ -215,6 +241,16 @@ | |
</td> | ||
<td>Generates code coverage report for the test task.</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<literal>jacocoTestCheck</literal> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: this task name doesn't represent what it's for IMO. Perhaps |
||
</td> | ||
<td>-</td> | ||
<td> | ||
<apilink class="org.gradle.testing.jacoco.tasks.JacocoCheck"/> | ||
</td> | ||
<td>Verifies code coverage metrics based on specified rules for the test task.</td> | ||
</tr> | ||
</table> | ||
</section> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any Jacoco docs we could link to too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above.