`Class not found: com.package.Class. Empty test su...
# android
m
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
miha-x64: check to make sure the product flavors of your modules are lined up correctly in the build variant section
m
@zak.taccardi I have no flavors and build variants in this module 🙂
Solved by adding
apply plugin: 'kotlin'
z
nice
t
I tried that and it failed at
apply plugin: 'kotlin-android'
😢
m
themarketka: What is the text of your error message? Which version of Kotlin plugin you are using?
t
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
Make sure all your modules with Kotlin contain appropriate ‘apply plugin’, this helped for me
t
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
I don’t know then 😞. Can you build the project?
t
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
androidTest.java.srcDirs += ‘src/main/kotlin’
looks suspiciously.
z
you should put kotlin files in src/main/java
no need for a second
src/main/kotlin
dir
t
I’ll try if it makes any difference!