Gradle Tutorial
Introduction Installation Creating project using command line Simple gradle project in IntelliJ IDEA build.gradle file settings.gradle file Directory structure of Gradle project Built-in tasks User defined tasks Task dependencies Running gradle tasks Grouping tasks Repository management in Gradle Declaring dependencies in Gradle JUnit TestNG Test execution reports in Gradle Creating executable Jar using Gradle Generating project API documentation in Gradle Publishing and deployment of artifact in GradleExecuting Junit tests in gradle
To use JUnit in your Gradle project, you will have to use below dependency.
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
We can execute the JUnit tests in a Gradle project by issuing below command.
gradle test
By default, this command will execute all test classes that end with Test or Tests To execute tests from specific classes
test –tests=junit.SimpleSuite
To execute tests from all classes in specific package
test –tests=junit.*
To execute specific test method
test –tests=junit.SimpleSuite.test2
To execute tests from specific category You need to use build.gradle file to specify the categories to be included and excluded. For example – In below configuration, all tests belonging to category CategoryX will be executed.
test{
useJUnit {
includeCategories 'categories.CategoryX'
excludeCategories 'categories.CategoryY'
}
}
Web development and Automation testing
solutions delivered!!