[JAVA] Gradle settings for using JUnit 5

A build.gradle sample for using JUnit 5 with Gradle.

--Repository

build.gralde


buildscript {
    ext {
        junitPlatformVersion = '1.0.1'
        junitJupiterVersion = '5.0.1'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.junit.platform:junit-platform-gradle-plugin:${junitPlatformVersion}"
    }
}

repositories {
    mavenCentral()
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.junit.platform.gradle.plugin'

compileTestJava {
    sourceCompatibility = targetCompatibility = 9
    options.compilerArgs += '-parameters'
}

dependencies {
    // JUnit Jupiter API and TestEngine implementation
    testCompile "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}"
    testRuntime "org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}"

    // To avoid compiler warnings about @API annotations in JUnit code
    testCompileOnly 'org.apiguardian:apiguardian-api:1.0.0'

    // Only needed to run tests in an (IntelliJ) IDE(A) that bundles an older version
    testRuntime "org.junit.platform:junit-platform-launcher:${junitPlatformVersion}"
}

task wrapper(type: Wrapper) {
    gradleVersion = '4.2.1'
    distributionType = Wrapper.DistributionType.ALL
}

--Reference

Recommended Posts

Gradle settings for using JUnit 5
[For beginners] I tried using JUnit 5 in Eclipse
Environment construction procedure for using PowerMock with JUnit
[For newcomers] Introducing JUnit
Try using letter_opener_web for inquiries
Gradle TIPS collection (for myself)
Using Docker from Java Gradle
Find out about annotationProcessor for Gradle 5.0
Automatically generate jpa entity using Gradle
[IntelliJ] 5 shortcut settings for convenient operation
I tried using JOOQ with Gradle
[OpenCV3.2.0] Eclipse (Java) settings (for Mac)
[Practice! ] Minimum settings when using MyBatis
Settings for SSL debugging in Java
JVM performance counter settings for ApplicationInsights.xml
Settings for SSH connection from Windows to Ubuntu using public key authentication