Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 378 Vote(s) - 3.48 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Android Studio - Kotlin Tests Throwing - Class not found - Empty test suite

#1
When trying to run espresso tests written in Kotlin on Android Studio (as far as 3.2 Canary 9), I'm getting the error:
Process finished with exit code 1
Class not found: "com.myproject.directoryofwinning.VerifyAppIsAwesomeTest"Empty test suite.

Strangely, Java tests in the same project have no issues.

Have tried to reset the configurations and suggested by others, but this doesn't seem to make any difference.
Reply

#2
In the end I found that it was down to "test" being added to the end of the classname. Either moving the word Test to the front of the classname, or omitting it all together resolves the issue.
Reply

#3
In my case using Android Studio 3.1.1, my Run/Debug Configurations were incorrect, probably due to to an automatic conversion of the config when updating Android Studio. **My instrumented test config ended up being placed under "Android JUnit" configs, instead of "Android Instrumented Tests".** Creating a new instrumented tests config for my particular class worked.

Also, the default configs created when right-clicking on my module's "Run All Tests" option fail to find my instrumented tests and run properly, resulting in

0 test classes found in package '<default package>'
Process finished with exit code 254
Empty test suite.

as the default config created popped up under Android JUnit. However, right-clicking on my package containing my instrumented tests creates it in the right category. I can also manually edit it to 'All in Module' and still execute my kotlin tests properly.

As an aside, I've also had the IDE give me the following misleading output before:

$ adb shell am instrument -w -r -e package com.base.package.kotlintests -e debug false com.base.package.test/android.support.test.runner.AndroidJUnitRunner
Client not ready yet..
Started running tests
Tests ran to completion.
Empty test suite.

Why did it say there was an empty test suite why I clearly have tests? Looking at the logs or running the `adb` command on a terminal revealed that my code was throwing an exception in my `@BeforeClass` setup! So no tests were executed, and everything completed trivially.
Reply

#4
Rebuild project, File > Invalidate Caches / Retart..., remove app\build folder, kill `adb` from processes, restart emulator.
Reply

#5
It took me a couple of tries to figure this out, but it ended up being due to missing the gradle changes needed to enable kotlin.

....
apply plugin: 'kotlin-android'
android {
....
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.21"
....
}
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through