Permalink
Browse files

Add jacoco test coverage and coveralls plugin

  • Loading branch information...
Flowdalic committed Jun 9, 2015
1 parent b72d0d8 commit b78d353c785a0ef3a514848c41a97673e59ef041
@@ -7,4 +7,6 @@ jdk:
- oraclejdk7

install: gradle assemble
script: gradle check
script: gradle check
after_success:
gradle jacocoRootReport coveralls
@@ -1,7 +1,7 @@
JXMPP
=====

[![Build Status](https://travis-ci.org/igniterealtime/jxmpp.svg)](https://travis-ci.org/igniterealtime/jxmpp) [![Project Stats](https://www.openhub.net/p/jxmpp/widgets/project_thin_badge.gif)](https://www.openhub.net/p/jxmpp)
[![Build Status](https://travis-ci.org/igniterealtime/jxmpp.svg)](https://travis-ci.org/igniterealtime/jxmpp) [![Project Stats](https://www.openhub.net/p/jxmpp/widgets/project_thin_badge.gif)](https://www.openhub.net/p/jxmpp) [![Coverage Status](https://coveralls.io/repos/igniterealtime/jxmpp/badge.svg)](https://coveralls.io/r/igniterealtime/jxmpp)

About
-----
@@ -1,10 +1,26 @@
import org.gradle.plugins.signing.Sign

buildscript {
repositories {
mavenCentral()
}

dependencies {
classpath "org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.4.0"
}
}

apply from: 'version.gradle'

allprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'jacoco'

repositories {
mavenLocal()
mavenCentral()
}

ext {
gitCommit = getGitCommit()
@@ -79,6 +95,19 @@ allprojects {
options.charSet = "UTF-8"
}

jacoco {
toolVersion = "0.7.4.201502262128"
}

jacocoTestReport {
dependsOn test
sourceDirectories = project.files(sourceSets.main.allSource.srcDirs)
classDirectories = project.files(sourceSets.main.output)
reports {
xml.enabled true
}
}

}

gradle.taskGraph.whenReady { taskGraph ->
@@ -136,10 +165,6 @@ subprojects {
checkstyle {
configFile = new File(rootConfigDir, 'checkstyle.xml')
}
repositories {
mavenLocal()
mavenCentral()
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
@@ -248,6 +273,27 @@ configure (androidProjects) {

test { dependsOn androidProjects*.compileAndroid }

apply plugin: "com.github.kt3k.coveralls"
coveralls {
sourceDirs = files(subprojects.sourceSets.main.allSource.srcDirs).files.absolutePath
}

task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
dependsOn = subprojects.jacocoTestReport
sourceDirectories = files(subprojects.sourceSets.main.allSource.srcDirs)
classDirectories = files(subprojects.sourceSets.main.output)
executionData = files(subprojects.jacocoTestReport.executionData)
reports {
xml.enabled true
xml.destination ="${buildDir}/reports/jacoco/test/jacocoTestReport.xml"
}
// We could remove the following setOnlyIf line, but then
// jacocoRootReport would silently be SKIPPED if something with
// the subprojects is wrong (e.g. a project is missing
// in there).
setOnlyIf { true }
}

def getGitCommit() {
def dotGit = new File("$projectDir/.git")
if (!dotGit.isDirectory()) return 'non-git build'
@@ -4,4 +4,5 @@ JXMPP Stringprep with libidn."""
dependencies {
compile project(':jxmpp-core')
compile 'org.gnu.inet:libidn:1.15'
}
testCompile 'junit:junit:4.11'
}
@@ -0,0 +1,32 @@
/**
*
* Copyright © 2015 Florian Schmaus
*
* 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.
*/
package org.jxmpp.stringprep.libidn;

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.jxmpp.stringprep.XmppStringprepException;

public class LibIdnXmppStringprepTest {

private static final LibIdnXmppStringprep stringprep = LibIdnXmppStringprep.getInstance();

@Test
public void simpleTest() throws XmppStringprepException {
assertEquals("foo", stringprep.localprep("FOO"));
}
}

0 comments on commit b78d353

Please sign in to comment.