This content originally appeared on DEV Community and was authored by Vincent Tsen
Manually edit run configuration as workaround for missing run test in Android Studio Bumblebee
This article was originally published at vtsen.hashnode.dev on March 28, 2022.
I noticed in Android Studio Bumblebee, we can't Run Test anymore from the Android Studio UI. It seems like is a known issue here and supposes it should be fixed in this version already, but somehow I still have the issue?
Expected Behavior
- From the source code editor
- From right click folder / file
Android Studio Bumblebee
- From the source code editor, it shows Nothing here
- From right click folder / file, Run Tests... menu is not there
Workarounds
I'm not a unit testing guy. Maybe I'm missing something here because it seems like no one complains about this? Anyway, these are the workarounds based on my limited knowledge in testing.
1. Use Different Android Studio Version
I guess you can roll back to previous stable release version Arctic Fox or upgrade to the latest preview version. I personally try Android Studio Dolphin (Canary build preview version) and have no issues.
2. Manually Edit Run Configuration
- Go to app->Edit Configuration...
- Add Gradle task
- Give the gradle task name (any name) and specify the gradle project (based on your project folder name)
- Add this Task
:app:testDebugUnitTest
- Add this Arguments
--tests "com.example.myapplication.ExampleUnitTest"
This run all test functions in
ExampleUnitTest
. If you want to run all classes within the package, you can use the*
--tests "com.example.myapplication.*"
To run unit test in command line, you can run the following command in the terminal
gradlew :app:testDebugUnitTest --tests "com.example.myapplication.ExampleUnitTest"
To run specific unit test function (e.g.
ExampleUnitTest.addition_isCorrect
), you just need to update the task to
:app:testDebugUnitTest --tests "com.example.myapplication.ExampleUnitTest.addition_isCorrect"
For instrument test, you also need to manually add it, similar to the unit test run configuration above.
- Go to app->Edit Configuration...
- Add Android Instrumented Tests
- Select ** All in Package**
- Select Module and Package
- So it looks like this
- Run the instrumented test (similar to the unit test above)
The above steps run all instrumented tests under the specify package. If you want to run test in specify class, just choose Class instead of All in Package and specify the class name you want to run.
To run instrumented test in command line, you can run the following command in the terminal
gradlew :app:connectedDebugAndroidTest
Conclusion
I feel troublesome to manually add the run configuration, especially I want to run a single test that is newly added. Maybe I should just move up my Android Studio version to the latest preview build to get rid of this problem.
See Also
This content originally appeared on DEV Community and was authored by Vincent Tsen
Vincent Tsen | Sciencx (2022-06-18T01:10:01+00:00) Missing Run Test in Android Studio. Retrieved from https://www.scien.cx/2022/06/18/missing-run-test-in-android-studio/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.