简体   繁体   中英

how to run all (unit and instrumented) tests with one click in Android Studio

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?

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 进行所有仪器化测试

  2. Then right click on ../app/src/test/java 进行所有单元测试

  3. Enjoy! =)

像这样

Use this way for all modules in a project.

1.Select Edit Configurations from Android Stduio

在此处输入图像描述

2.Add Gradle task

在此处输入图像描述

3. Set this config

cleanTestDebugUnitTest testDebugUnitTest

--tests "*"

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM