mirror of
https://github.com/MinimalBible/MinimalBible
synced 2025-08-28 02:04:46 -04:00
Code coverage is working!
Been trying so long to get this running, so happy to have it done.
This commit is contained in:
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(""), "")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user