Last active
September 28, 2020 22:21
-
-
Save jenschude/9619ba13a9e7743368ed07b21dad6179 to your computer and use it in GitHub Desktop.
Foo.java
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
run with ```./gradlew clean test cloverGenerateReport``` |
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
group 'foo' | |
version '1.0-SNAPSHOT' | |
apply plugin: 'java' | |
apply plugin: 'com.bmuschko.clover' | |
apply plugin: 'idea' | |
sourceCompatibility = 1.8 | |
repositories { | |
mavenCentral() | |
} | |
buildscript { | |
repositories { | |
jcenter() | |
} | |
dependencies { | |
classpath 'com.bmuschko:gradle-clover-plugin:2.2.0' | |
} | |
} | |
dependencies { | |
testCompile group: 'junit', name: 'junit', version: '4.12' | |
testCompile 'org.assertj:assertj-core:3.8.0' | |
clover 'org.openclover:clover:4.2.0' | |
} | |
test { | |
reports { | |
junitXml.enabled = true | |
html.enabled = true | |
} | |
} | |
clover { | |
excludes = ['**/SynchronizedMultiValueMap.java'] | |
// This is the default testIncludes configuration | |
testIncludes = ['**/*Test.java', '**/*Spec.groovy'] | |
testExcludes = ['**/Mock*.java'] | |
targetPercentage = '0%' | |
// Closure based syntax for additionalSourceSets and | |
// additionalTestSourceSets is also supported. Both | |
// srcDirs and classesDir properties are required. | |
// The syntax allows the following to occur as many times | |
// as necessary to define each additional sourceSet. | |
// From version 3.0.0 and later the configuration is | |
// requiring the Gradle 4.0 outputDir for each language | |
// in the sourceSet. If you have Java and Groovy sourceSets | |
// you may need to specify each language in the sourceSet | |
// separately. | |
compiler { | |
encoding = 'UTF-8' | |
// if the javac executable used by ant should be the same as the one used elsewhere. | |
executable = file('/usr/local/java/jdk1.8.0_05') | |
// used to add debug information for Spring applications | |
debug = true | |
additionalArgs = '-parameters' | |
} | |
contexts { | |
statement { | |
name = 'log' | |
regexp = '^.*LOG\\..*' | |
} | |
method { | |
name = 'main' | |
regexp = 'public static void main\\(String args\\[\\]\\).*' | |
} | |
method { | |
name = 'getters' | |
regexp = 'public [^\\s]+ get[A-Z][^\\s]+\\(\\)' | |
maxStatements = 1 | |
} | |
method { | |
name = 'setters' | |
regexp = 'public void set[A-Z][^\\s]+\\(.+\\)' | |
maxStatements = 1 | |
} | |
} | |
report { | |
html = true | |
pdf = true | |
xml = true | |
filter = 'log,main,getters,setters' | |
// Support capturing test results from JUnix XML report | |
testResultsDir = project.tasks.getByName('test').reports.junitXml.destination | |
testResultsInclude = 'TEST-*.xml' | |
// Clover report nested columns support | |
columns { | |
coveredMethods format: 'longbar', min: '75' | |
coveredStatements format: '%' | |
coveredBranches format: 'raw' | |
totalPercentageCovered format: '%', scope: 'package' | |
} | |
// Clover history generation support | |
// See Clover documentation for details of the values supported | |
historical { | |
enabled = true | |
historyIncludes = 'clover-*.xml.gz' | |
packageFilter = null | |
from = null | |
to = null | |
added { | |
range = 10 | |
interval = '3 weeks' | |
} | |
mover { | |
threshold = 1 | |
range = 10 | |
interval = '3 weeks' | |
} | |
mover { | |
threshold = 1 | |
range = 10 | |
interval = '3 months' | |
} | |
mover { | |
threshold = 1 | |
range = 10 | |
interval = '1 year' | |
} | |
} | |
} | |
} |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<coverage generated="1516617614096" clover="4.2.0"> | |
<project name="foo" timestamp="1516617613431"> | |
<metrics coveredelements="6" complexity="2" loc="11" methods="1" classes="1" statements="3" packages="1" coveredconditionals="2" coveredmethods="1" elements="6" ncloc="10" files="1" conditionals="2" coveredstatements="3"/> | |
<package name="default-pkg"> | |
<metrics coveredelements="6" complexity="2" loc="11" methods="1" classes="1" statements="3" coveredconditionals="2" coveredmethods="1" elements="6" ncloc="10" files="1" conditionals="2" coveredstatements="3"/> | |
<file path="/Users/jensschulze/workspace/foo/src/main/java/Foo.java" name="Foo.java"> | |
<metrics coveredelements="6" coveredconditionals="2" complexity="2" loc="11" coveredmethods="1" methods="1" elements="6" classes="1" ncloc="10" statements="3" conditionals="2" coveredstatements="3"/> | |
<class name="Foo"> | |
<metrics coveredelements="6" coveredconditionals="2" complexity="2" coveredmethods="1" methods="1" elements="6" statements="3" conditionals="2" coveredstatements="3"/> | |
</class> | |
<line complexity="2" visibility="public" signature="bar(int,int) : boolean" num="3" count="2" type="method"/> | |
<line num="5" count="2" type="stmt"/> | |
<line falsecount="1" truecount="1" num="5" type="cond"/> | |
<line num="6" count="1" type="stmt"/> | |
<line num="9" count="1" type="stmt"/> | |
</file> | |
</package> | |
</project> | |
<testproject name="foo" timestamp="1516617613431"> | |
<metrics coveredelements="4" complexity="1" loc="15" methods="1" classes="1" statements="3" packages="1" coveredconditionals="0" coveredmethods="1" elements="4" ncloc="11" files="1" conditionals="0" coveredstatements="3"/> | |
<package name="default-pkg"> | |
<metrics coveredelements="4" complexity="1" loc="15" methods="1" classes="1" statements="3" coveredconditionals="0" coveredmethods="1" elements="4" ncloc="11" files="1" conditionals="0" coveredstatements="3"/> | |
<file path="/Users/jensschulze/workspace/foo/src/test/java/FooTest.java" name="FooTest.java"> | |
<metrics coveredelements="4" coveredconditionals="0" complexity="1" loc="15" coveredmethods="1" methods="1" elements="4" classes="1" ncloc="11" statements="3" conditionals="0" coveredstatements="3"/> | |
<class name="FooTest"> | |
<metrics coveredelements="4" complexity="1" methods="1" testruns="1" statements="3" coveredconditionals="0" coveredmethods="1" elements="4" testfailures="0" testduration="0.09399999678134918" conditionals="0" coveredstatements="3" testpasses="1"/> | |
</class> | |
<line complexity="1" visibility="public" signature="one() : void" num="8" testsuccess="true" count="1" testduration="0.09399999678134918" type="method"/> | |
<line num="10" count="1" type="stmt"/> | |
<line num="12" count="1" type="stmt"/> | |
<line num="13" count="1" type="stmt"/> | |
</file> | |
</package> | |
</testproject> | |
</coverage> |
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
public class Foo | |
{ | |
public boolean bar(int a, int b) | |
{ | |
if (a == b) { | |
return false; | |
} | |
return true; | |
} | |
} |
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
import org.junit.Test; | |
import static org.assertj.core.api.Assertions.assertThat; | |
public class FooTest | |
{ | |
@Test | |
public void one() { | |
Foo foo = new Foo(); | |
assertThat(foo.bar(1, 2)); | |
assertThat(!foo.bar(1, 1)); | |
} | |
} |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<testsuite name="FooTest" tests="1" skipped="0" failures="0" errors="0" timestamp="2018-01-22T10:40:12" hostname="Jenss-MacBook-Pro-2.local" time="0.094"> | |
<properties/> | |
<testcase name="one" classname="FooTest" time="0.094"/> | |
<system-out><![CDATA[]]></system-out> | |
<system-err><![CDATA[]]></system-err> | |
</testsuite> |
Is there an ETA on this or any works in progress that can use some help getting across the finish line?
It is unfortunate that Clover is widely supported by many tools, but that coverage features cannot be used with those tools on account of the invalid syntax (for example, AWS CodeBuild).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.dropbox.com/s/c9zp2zcpy393l29/foo.zip?dl=0