https://kotlinlang.org logo
#android
Title
# android
m

miha-x64

01/28/2017, 8:49 PM
Class not found: com.package.Class. Empty test suite.
Android Studio, why? Some of details. Trying to test Java Library module in AS which depends ob another Java Library and another library's test-scope classes. Java tests work. Why?
z

zak.taccardi

01/29/2017, 10:20 AM
miha-x64: check to make sure the product flavors of your modules are lined up correctly in the build variant section
m

miha-x64

01/29/2017, 10:31 AM
@zak.taccardi I have no flavors and build variants in this module 🙂
Solved by adding
apply plugin: 'kotlin'
z

zak.taccardi

01/30/2017, 2:48 PM
nice
t

themarketka

02/03/2017, 12:41 PM
I tried that and it failed at
apply plugin: 'kotlin-android'
😢
m

miha-x64

02/03/2017, 12:47 PM
themarketka: What is the text of your error message? Which version of Kotlin plugin you are using?
t

themarketka

02/03/2017, 12:54 PM
It keeps saying "Empty test suite.", sometimes "class not found" with the class that contains the tests, plugin
1.0.6-release-IJ2016.3-1
m

miha-x64

02/03/2017, 12:55 PM
Make sure all your modules with Kotlin contain appropriate ‘apply plugin’, this helped for me
t

themarketka

02/03/2017, 12:56 PM
Copy code
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric'
apply plugin: 'com.getkeepsafe.dexcount'
that’s in the tested module’s build.gradle
m

miha-x64

02/03/2017, 12:57 PM
I don’t know then 😞. Can you build the project?
t

themarketka

02/03/2017, 12:58 PM
Maybe I’m running the tests wrong… The project builds and runs fine, it just can’t find the tests, like if the class with test wasn’t even on classpath or something
Even unit tests alone work, but not these instrumentation ones (
@RunWith(AndroidJUnit4::class)
)
Might be a good thing to see if the same would run were it in the
androidTest/java
dir as Java instead of
androidTest/kotlin
.
And yes, I have this:
Copy code
sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
        test.java.srcDirs += 'src/test/kotlin'
        androidTest.java.srcDirs += 'src/main/kotlin'
        androidTest.java.srcDirs += 'src/androidTest/kotlin'
        ...
}
m

miha-x64

02/03/2017, 1:16 PM
androidTest.java.srcDirs += ‘src/main/kotlin’
looks suspiciously.
z

zak.taccardi

02/03/2017, 4:36 PM
you should put kotlin files in src/main/java
no need for a second
src/main/kotlin
dir
t

themarketka

02/05/2017, 6:11 PM
I’ll try if it makes any difference!
2 Views