15

I am developing an Android app in Android Studio. I have unit tests and instrumented tests.

I want to run them all to see if I broke something.

Right now my workflow is:

  • go to Project view
    • navigate to ${app}/src/androidTest/java/
    • right-click that node and select Run 'All Tests'
    • select my device
    • run instrumented tests

then

  • go to Project view
    • navigate to ${app}/src/androidTest/java/${package}
    • right-click that node and select Run 'Tests in ${package}'
    • run unit tests

What I am really looking for is a big green button that runs all of the tests and reports back the result of OK/FAILED for both unit and instrumented tests together. How can I do that?

mnagel
  • 6,189
  • 4
  • 28
  • 63

2 Answers2

7

You cannot start both tests at the same time...

But you can create two big green buttons.

  1. Go to your project files and right click on ../app/src/androidTest/java make all instrumented tests

  2. Then right click on ../app/src/test/java make all unit tests

  3. Enjoy! =)

like this

Andrew Grow
  • 617
  • 7
  • 15
  • 2
    The above answer works if you only have one module. If you have multiple modules and want to run all of your tests for all modules in that project, check out my answer: https://stackoverflow.com/a/56192783/2441420 – blueberry_chopsticks May 17 '19 at 20:05
  • this sucks. The root principle of TDD editing is you run _all_ tests with _one_ button. Not "different tests because..." – Phlip Sep 08 '21 at 19:53
0

Use this way for all modules in a project.

1.Select Edit Configurations from Android Stduio

enter image description here

2.Add Gradle task

enter image description here

3. Set this config

cleanTestDebugUnitTest testDebugUnitTest

--tests "*"

enter image description here

Rasoul Miri
  • 7,206
  • 57
  • 67