Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto run tests before app build in Android Studio

I've written two test cases LoginTest and SignUpTest using JUnit and a Test Suite SessionUnitTestSuite. Every time I want to build and run my app, I have to run the test suite (by selecting the Test Suite and then clicking in "Run") before and, if the test passes, run my app (by selecting the app module and then clicking in "Run").

Is there a way to automatically run the tests before running my app module and cancel the installation of my app if the tests fail?

like image 960
regmoraes Avatar asked Mar 08 '26 10:03

regmoraes


1 Answers

Go to Run/Debug Configurations, and select your application configuration. At the bottom of the right panel, under Before launch:, click the + button, and select Run another configuration. There, choose the configuration for running your tests.

enter image description here

like image 128
nhaarman Avatar answered Mar 10 '26 23:03

nhaarman