Android studio: How to re run unit test automatically at file change?

Viewed 63

Coming from Typescript using Jest there I could send the --watch flag and every time I changed the test file the test will automatically run.

Is there something similar with Android Studio using JUnit5 ?

1 Answers

This can be achieved using Gradle 6.7 or higher. Adding --watch-fs enables Gradle's fs watcher. You might want to also include -Dorg.gradle.vfs.verbose=true to get more information about the virtual fs state and events it received.

Example to run tests:

./gradlew --watch-fs -Dorg.gradle.vfs.verbose=true test

Related