I have a simple Kotlin classes, as below
class MyClass {
fun justSayHello(yes: Boolean): String {
if (yes) {
return "Hello"
} else {
return "Sorry"
}
}
}
I have my test (written in Java here, could be in Kotlin, also)
public class MyClassTest {
private MyClass myClass = new MyClass();
@Test
public void testFirst() {
myClass.justSayHello(true);
}
@Test
public void testSecond() {
myClass.justSayHello(false);
}
}
When I run a test with Coverage in Android Studio 3.0 Beta-2 using classpath 'com.android.tools.build:gradle:3.0.0-beta2'
, no coverage is reported for it.
But when I run the test using classpath 'com.android.tools.build:gradle:2.3.3'
, 100% coverage reported.
When I change my source code to Java:
public class MyClass {
public String justSayHello(boolean yes) {
if (yes) {
return "Hello";
} else {
return "Sorry";
}
}
}
It works fine for both gradle build tools
It seems to me that 'com.android.tools.build:gradle:3.0.0-beta2'
has the broken test coverage measurement for Kotlin.
Did I miss anything? Is there a workaround for me to get the test coverage in Kotlin?