EDIT: Infinitest does work for gradle projects; see accepted answer. Below merely serves as an alternative using gradle itself (but Infinitest provides faster feedback on test passing/failing)
It appears that the Infinitest plug-in for IntelliJ does not work for gradle projects. Alternatively you can use the semi-new continuous mode of gradle itself for continuous testing:
- Create a run configuration for running the test task in gradle. The easiest way I know of is to find the test task in the Gradle view (View -> Tool Windows -> Gradle), expand your root project -> Tasks -> verification -> test (double click)
- Edit that run configuration to add the --continuous argument: From the run configurations dropdown select "Edit Configurations...", then add
--continuous
to the Script parameters field.
- Run the configuration. This time, after building and running tests the first time, Gradle's console output will say
Waiting for changes to input files of tasks...
. Once you save changes to a file (you may have to press Ctrl+S), it will run the tests again.
It's not nearly as nice as say NCrunch for .NET -- it can't run only affected tests; it has to run all of them, which creates a slower "continuousness". But it does the job. Also, Gradle 2.11 (the newest at the time of writing this) admits "Continuous build is an incubating feature", which gives us hope for improvements in the future.