isaac.udy
isaac.udy

Reputation: 188

Run a specific test every time an Android app is built in Android Studio

I would like to run a specific test fixture every time I build my Android application in Android Studio.

I've tried writing a custom task, and causing "preDebugBuild" to depend on my custom task. This doesn't work, and says that it fails to find dependencies.

My task body basically looks like this:

task runTests(type: Test){

}

I had hoped that this task would run all the tests in my project, and that I would then be able to put in some additional configuration to specify a single test, but I can't even get this task to run.

My questions are:

  1. Is there something easy that I am missing to get my "runTests" task to actually work.

  2. Is there some other way to run a specific unit test during the build preDebugBuild step of the Gradle build?

Thanks!

Upvotes: 1

Views: 600

Answers (1)

user1892364
user1892364

Reputation: 269

In the Run/Debug Configuration (click on "Edit Configuration" in the selector on the left side of the run button) you can select the "+" button on the bottom and select "Run Another Configuration" and a list of your unit tests should show up.

Upvotes: 1

Related Questions