Missing Run Test in Android Studio
Tags: android, beginners
Published: 2022-06-18 01:10:01

**Manually edit run configuration as workaround for missing run test in Android Studio Bumblebee**

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](https://issuetracker.google.com/issues/194634663) and supposes it should be fixed in this version already, but somehow I still have the issue?

## Expected Behavior
- From the source code editor
![Missing_Run_Test_in_Android_Studio_BumbleBee_01.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1649389706747/sEW31qzMK.gif)
- From right click folder / file
![Missing_Run_Test_in_Android_Studio_BumbleBee_02.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1649389941335/9oIKlXbk2.gif)

## Android Studio Bumblebee
- From the source code editor, it shows **Nothing here**
![Missing_Run_Test_in_Android_Studio_BumbleBee_03.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1649390190478/fqEy27Tua.gif)
- From right click folder / file, **Run Tests...** menu is not there
![Missing_Run_Test_in_Android_Studio_BumbleBee_04.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1649390476024/YeZit1w3n.gif)

## 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...**
![Missing_Run_Test_in_Android_Studio_BumbleBee_05.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1649392273966/Bu6rsgG95.gif)
- 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.*"
```

- So it looks like this
![Missing_Run_Test_in_Android_Studio_BumbleBee_06.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649639048649/eU-c9BRln.png)

- Run the unit test
![Missing_Run_Test_in_Android_Studio_BumbleBee_07.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1649393039789/ZaJnnYCpA.gif)

> 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
![Missing_Run_Test_in_Android_Studio_BumbleBee_08.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1649394441121/tRSZBWzZz.png)
- 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.

---

*Originally published at [https://vtsen.hashnode.dev](https://vtsen.hashnode.dev/missing-run-test-in-android-studio)*.