mirror of
https://github.com/MinimalBible/MinimalBible
synced 2024-11-04 23:28:19 -05:00
Code coverage is working!
Been trying so long to get this running, so happy to have it done.
This commit is contained in:
parent
8d6a3b0d84
commit
cb8ea71f62
15
.travis.yml
15
.travis.yml
@ -1,14 +1,3 @@
|
|||||||
language: android
|
language: java
|
||||||
env:
|
|
||||||
matrix:
|
|
||||||
- ANDROID_SDKS=android-19,sysimg-19 ANDROID_TARGET=android-19 ANDROID_ABI=armeabi-v7a
|
|
||||||
|
|
||||||
before_install:
|
script: "bash gradlew jacocoTestReport"
|
||||||
- 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"
|
|
1
app-test/.gitignore
vendored
Normal file
1
app-test/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/build
|
32
app-test/build.gradle
Normal file
32
app-test/build.gradle
Normal file
@ -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
|
@ -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<String> by Delegates.notNull()
|
||||||
|
|
||||||
|
Before fun setUp() {
|
||||||
|
delegate = SafeValDelegate()
|
||||||
|
}
|
||||||
|
|
||||||
|
Test(expected = javaClass<IllegalStateException>())
|
||||||
|
fun testDelegateNullSafety() {
|
||||||
|
delegate.get(null, PropertyMetadataImpl(""))
|
||||||
|
}
|
||||||
|
|
||||||
|
Test(expected = javaClass<IllegalStateException>())
|
||||||
|
fun testDelegateAssignOnce() {
|
||||||
|
delegate.set(null, PropertyMetadataImpl(""), "")
|
||||||
|
delegate.set(null, PropertyMetadataImpl(""), "")
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,9 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '0.9.206'
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
|
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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<String> delegate;
|
|
||||||
|
|
||||||
public void setUp() {
|
|
||||||
delegate = new SafeValDelegate<String>();
|
|
||||||
}
|
|
||||||
|
|
||||||
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!");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +1,14 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
|
ext.kotlin_version = '0.9.206'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:0.12.+'
|
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
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
include ':app'
|
include ':app', ':app-test'
|
||||||
include ':jsword-minimalbible'
|
include ':jsword-minimalbible'
|
||||||
|
Loading…
Reference in New Issue
Block a user