Book Image

Mastering Gradle

Book Image

Mastering Gradle

Overview of this book

Table of Contents (17 chapters)
Mastering Gradle
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Testing with Gradle


No piece of software is production ready unless it passes through a proper quality check. It helps to deliver software with minimum defects and saves lots of maintenance effort. However, manual test execution requires lots of time to execute tests and therefore the software release cycle is delayed. Release time and productivity can be improved if tests are automated.

Gradle provides an automated way to execute test code, especially for unit tests. In the following section, we'll explore how to integrate JUnit and TestNG with Gradle.

JUnit

Gradle's Java plugin provides a predefined structure to keep test code and test resources for configuration and execution. As with the source code structure, the default test code location is src/test/java/<test_package>. If you follow this convention, you just need to execute the test task to run the unit test cases as shown in the following command:

$ gradle test
:compileJava
:processResources
:classes
:compileTestJava
:processTestResources...