I created a very simple test function as below
class SimpleClassTest {
lateinit var simpleObject: SimpleClass
@Mock lateinit var injectedObject: InjectedClass
@Before
fun setUp() {
MockitoAnnotations.initMocks(this)
}
@Test
fun testSimpleFunction() {
simpleObject = lookupInstance()
}
inline fun lookupInstance() = SimpleClass(injectedObject)
}
I Run it with Coverage... The test coverage number is 0%. But if I remove the inline
keyword, the test coverage number shows now.
Is this a Kotlin issue or Android IntelliJ IDEA Coverage issue? (note: JaCoco coverage is good).
Note: I'm using Android Studio 2.0 and Kotlin 1.0.2
When an inlined function is compiled, the compiler essentially pastes its body into the call site (in place of the function call). This means that the coverage analysis can't tell that it's an inlined function because it doesn't really exist where you defined it. In other words, this behavior is a natural artifact of what it means for a function to be inlined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With