diff --git a/build.gradle b/build.gradle index da6e308..d44b8bb 100644 --- a/build.gradle +++ b/build.gradle @@ -21,6 +21,8 @@ allprojects { version = project.version apply plugin: 'checkstyle' apply plugin: 'maven-publish' + apply plugin: 'java' + apply plugin: 'jacoco' repositories { mavenLocal() @@ -59,8 +61,29 @@ def stripBallerinaExtensionVersion(String extVersion) { } } +tasks.register('codeCoverageReport', JacocoReport) { + dependsOn = subprojects.test + + executionData fileTree(project.rootDir.absolutePath).include("**/build/coverage-reports/*.exec") + + subprojects.each { + sourceSets it.sourceSets.main + } + reports { + xml.required = true + html.required = true + csv.required = true + xml.destination(new File("${buildDir}/reports/jacoco/report.xml")) + html.destination(new File("${buildDir}/reports/jacoco/report.html")) + csv.destination(new File("${buildDir}/reports/jacoco/report.csv")) + } + + onlyIf = { + true + } +} + subprojects { - apply plugin: 'java' configurations { ballerinaStdLibs } diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..c3dda58 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,11 @@ +ignore: + - "copybook-tool" + +coverage: + precision: 2 + round: down + range: "60...80" + status: + project: + default: + target: auto diff --git a/copybook-cli/build.gradle b/copybook-cli/build.gradle index 2097578..02a74ec 100644 --- a/copybook-cli/build.gradle +++ b/copybook-cli/build.gradle @@ -59,6 +59,20 @@ tasks.register('copyJar', Copy) { into "$rootDir/copybook-tool/build/libs" } +jacoco { + toolVersion = "${jacocoVersion}" +} + +jacocoTestReport { + dependsOn test + def classFiles = new File("${rootDir}/copybook-cli/build/classes/java/main/io/ballerina/tools/copybook") + additionalClassDirs(classFiles) + reports { + xml.required = true + html.required = true + } +} + checkstyleMain.dependsOn(":checkstyle:downloadCheckstyleRuleFiles") checkstyleTest.dependsOn(":checkstyle:downloadCheckstyleRuleFiles") @@ -66,6 +80,20 @@ test { useTestNG() { suites "src/test/resources/testng.xml" } + + testLogging.showStandardStreams = true + testLogging { + events "PASSED", "FAILED", "SKIPPED" + afterSuite { desc, result -> + if (!desc.parent) { + def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)" + def startItem = '| ', endItem = ' |' + def repeatLength = startItem.length() + output.length() + endItem.length() + println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength)) + } + } + } + finalizedBy jacocoTestReport } spotbugsMain { diff --git a/gradle.properties b/gradle.properties index 85a08b9..7795b07 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,3 +14,4 @@ copybookParserVersion=0.1.0-SNAPSHOT testngVersion=7.7.0 slf4jVersion=2.0.9 antlrVersion=4.13.1 +jacocoVersion=0.8.10