This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes Gradle forcing test task to run Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Gradle forcing test task to run" Watch "Gradle forcing test task to run" New topic

Gradle forcing test task to run

Wirianto Djunaidi
Ranch Hand

Joined: Mar 20, 2001
Posts: 210

I'm playing with Gradle at this moment and I notice that Gradle is quite smart in term of not running any of the tasks when nothing has changed, including the 'test' task. However sometime I do want to run the test task even when nothing has changed, because I want to look at the test report in the case I lost the console buffer already. What is the way to force the test task to run even when there is no change to the project? Of course I'm looking for idiomatic Gradle way, not touching the project to fake a change .
Hubert Klein Ikkink

Joined: Jan 10, 2013
Posts: 13

Hi Wirianto,

the easiest way is to first run cleanTest before the test task. So from the command-line you would enter:
$ gradle cleanTest test
or using task abbreviation:
$ gradle cT test

If you always want to run the test task you can add in your build file:
test.dependsOn 'cleanTest'
or define the task can never be UP-TO-DATE:
test.outputs.updateWhen { false }
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Gradle forcing test task to run
It's not a secret anymore!