Categories: Softwares

Missing Run Test in Android Studio

[ad_1]

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
Enter fullscreen mode

Exit fullscreen mode

--tests "com.example.myapplication.ExampleUnitTest"
Enter fullscreen mode

Exit fullscreen mode

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.*"
Enter fullscreen mode

Exit fullscreen mode

  • So it looks like this

  • Run the unit test

To run unit test in command line, you can run the following command in the terminal

gradlew :app:testDebugUnitTest --tests "com.example.myapplication.ExampleUnitTest"
Enter fullscreen mode

Exit fullscreen mode

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"
Enter fullscreen mode

Exit fullscreen mode

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
Enter fullscreen mode

Exit fullscreen mode

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

[ad_2]

Source link

Taylor Swift

Taylor Swift is a pro-level blogger with years of experience in writing for multiple industries. She has extensive knowledge in Technology, healthcare, business, sports, fashion, and many other popular niches.

Recent Posts

How To Choose the Right Sales Automation Solution

In the relentless pace of today's business landscape, where time is money and efficiency is… Read More

2 weeks ago

Benefits of Group Dog Training: Why Socializing Your Pup Matters

When it comes to raising a well-rounded and well-behaved canine companion, socialization plays a crucial… Read More

2 weeks ago

All Characters Who Trained Luke Skywalker

Luke Skywalker, the legendary Jedi Knight who ignited a new hope in the galaxy, didn't… Read More

2 weeks ago

Top 8 Tips to Find the Best Dental Clinic in Dubai [2024]

When it comes to your dental health, choosing the right clinic is crucial for receiving… Read More

3 weeks ago

Essentials for Effective Multifamily Marketing

In the dynamic world of real estate, multifamily properties present unique marketing challenges and opportunities.… Read More

4 weeks ago

How Couples Salsa Classes Can Strengthen Your Relationship

In the bustling world we inhabit, finding meaningful ways to connect with our partners can… Read More

1 month ago