diff --git a/.travis.yml b/.travis.yml index dd37e02..762df1b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,3 @@ -language: android -env: - matrix: - - ANDROID_SDKS=android-19,sysimg-19 ANDROID_TARGET=android-19 ANDROID_ABI=armeabi-v7a +language: java -before_install: - - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI - - emulator -avd test -no-skin -no-audio -no-window & - -before_script: - - bash ./wait_for_emulator - - adb shell input keyevent 82 & - -script: "bash gradlew connectedAndroidTestTestConfigDebug" \ No newline at end of file +script: "bash gradlew jacocoTestReport" \ No newline at end of file diff --git a/app-test/.gitignore b/app-test/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app-test/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app-test/build.gradle b/app-test/build.gradle new file mode 100644 index 0000000..eb5423d --- /dev/null +++ b/app-test/build.gradle @@ -0,0 +1,32 @@ +apply plugin: 'java' +apply plugin: 'kotlin' +apply plugin: 'jacoco' + +def androidModule = project(':app') + +dependencies { + compile androidModule + + testCompile androidModule.android.applicationVariants.toList().first().javaCompile.classpath + testCompile androidModule.android.applicationVariants.toList().first().javaCompile.outputs.files + testCompile files(androidModule.plugins.findPlugin("com.android.application").getBootClasspath()) + + testCompile 'junit:junit:4.+' + testCompile 'org.robolectric:robolectric:2.2' +} + +jacocoTestReport { + // Add Android sources/classes for coverage + additionalSourceDirs files(androidModule.android.sourceSets.main.java.srcDirs) + additionalClassDirs androidModule.android.applicationVariants + .toList().first().javaCompile.outputs.files + + reports { + xml.enabled true + csv.enabled false + html.destination "${buildDir}/jacocoHtml" + } +} + +// Code coverage should depend on the tests +project.jacocoTestReport.dependsOn project.test diff --git a/app-test/src/test/kotlin/org/bspeice/minimalbible/SafeValDelegateKotlinTest.kt b/app-test/src/test/kotlin/org/bspeice/minimalbible/SafeValDelegateKotlinTest.kt new file mode 100644 index 0000000..61ba61f --- /dev/null +++ b/app-test/src/test/kotlin/org/bspeice/minimalbible/SafeValDelegateKotlinTest.kt @@ -0,0 +1,25 @@ +package org.bspeice.minimalbible + +import org.junit.Before +import org.junit.Test +import kotlin.properties.Delegates + +class SafeValDelegateKotlinTest { + + var delegate: SafeValDelegate by Delegates.notNull() + + Before fun setUp() { + delegate = SafeValDelegate() + } + + Test(expected = javaClass()) + fun testDelegateNullSafety() { + delegate.get(null, PropertyMetadataImpl("")) + } + + Test(expected = javaClass()) + fun testDelegateAssignOnce() { + delegate.set(null, PropertyMetadataImpl(""), "") + delegate.set(null, PropertyMetadataImpl(""), "") + } +} \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 2d96993..0c6c2bb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,12 +1,9 @@ buildscript { - ext.kotlin_version = '0.9.206' - repositories { mavenCentral() } dependencies { classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/app/src/androidTest/java/org/bspeice/minimalbible/test/SafeValDelegateTest.java b/app/src/androidTest/java/org/bspeice/minimalbible/test/SafeValDelegateTest.java deleted file mode 100644 index c4addcf..0000000 --- a/app/src/androidTest/java/org/bspeice/minimalbible/test/SafeValDelegateTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.bspeice.minimalbible.test; - -import org.bspeice.minimalbible.MBTestCase; -import org.bspeice.minimalbible.SafeValDelegate; - -import kotlin.PropertyMetadataImpl; - -/** - * Test that the FinalDelegate actually obeys its contract - */ -public class SafeValDelegateTest extends MBTestCase { - - SafeValDelegate delegate; - - public void setUp() { - delegate = new SafeValDelegate(); - } - - public void testDelegateNullSafety() { - try { - delegate.get(null, new PropertyMetadataImpl("")); - } catch (IllegalStateException e) { - return; - } - - fail("Exception not thrown!"); - } - - public void testDelegateAssignOnce() { - try { - delegate.set(null, new PropertyMetadataImpl(""), ""); - delegate.set(null, new PropertyMetadataImpl(""), ""); - } catch (IllegalStateException e) { - return; - } - - fail("Allowed to set twice!"); - } -} diff --git a/build.gradle b/build.gradle index a75fc81..0f7022e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,14 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { + ext.kotlin_version = '0.9.206' + repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:0.12.+' - + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/settings.gradle b/settings.gradle index 0b6bec1..7aaccf7 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,2 @@ -include ':app' +include ':app', ':app-test' include ':jsword-minimalbible'