Skip to content

Instantly share code, notes, and snippets.

View mfebrianto's full-sized avatar

michael febrianto mfebrianto

View GitHub Profile
object ExampleSpec : Spek({
describe("simple test") {
it("returns true") {
assertTrue(true)
}
}
})
@Mock
Activity mock
@RunWith(RobolectricTestRunner.class)
public class MyActivityTest {
}
private val mContext = mockk<Context>
class IronManMk1 {
fun getRepulsorsStatus() {
println("jarvis: repulsors no power")
}
val repulsorsStatus = println("jarvis: repulsors no power")
}
class IronManMk2 {
fun getRepulsorsStatus() {
println("jarvis: ready power 100")
}
val repulsorsStatus get() = println("jarvis: ready power 90")
}
class IronManMk1Debug {
fun shoot() {
println("jarvis: target destroyed")
}
fun getRepulsorsStatus() {
println("jarvis: repulsors no power")
}
val repulsorsStatus = println("jarvis: repulsors no power")
buildscript {
ext.jacocoVersion = '0.8.7'
repositories {
google()
jcenter()
}
dependencies {
classpath "org.jacoco:org.jacoco.core:$jacocoVersion"
apply plugin: 'jacoco'
android {
debug {
// this line will add new task createDebugCoverageReport that needed by jacoco
// however as default it will generate coverage for androidTest
// it does not generate coverage for unitTest
testCoverageEnabled true
}
}
task jacocoTestCoverageVerification(type: JacocoCoverageVerification, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) {
group = "Verification"
description = "Check code coverage"
onlyIf = {
true
}
violationRules {
rule {