Main Tutorials

Gradle – How to skip unit test

Be default, Gradle build is abort if any unit tests is failed. Oftentimes, we still need to build the project even the unit test is failed.

To skip the entire unit tests in Gradle build, uses this option-x test


gradle build -x test

Review a sample output :

1. Default Gradle build :

 
$ gradle build
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:assemble UP-TO-DATE
---------------------------> Unit test task
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
---------------------------> Unit test task
:test
:check
:build

2. Gradle build with unit test skipped :


$ gradle build -x test
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:assemble UP-TO-DATE
---------------------------> Unit test task

---------------------------> Unit test task
:check
:build

References

  1. Gradle user guide – Excluding tasks
  2. How To Skip Maven Unit Test

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
4 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Carol
5 years ago

Thanks, very clear !

Sushil Mejari
4 years ago

How to run specific test immediate after build – while running command gradle build

Cristiano Gregio
4 years ago
Reply to  Sushil Mejari

I guess in this case you have to create a specific task in Gradle and then run it instead of call this default task (build).

Daniel Lorell
3 years ago

This is sexy