As I understand it (and I'm still learning), you need to use the JUni4 based runner in order to run & view the results in Intellij (src JUnit5 docs). To do this you would need to enable the junit-platform-runner artifact in you gradle.build file. On that note, the gradle.build file examples presented seem a bit more complicated than what you have presented.
I finally got JUnit5 up in Intellij by starting with the gradle.build file shown in the junit5-gradle-consumer example, playing with it, banging my head, etc, until I got it working. There are still differences when I run the tests in the console with gradle and running them in Intellij. Sometimes Intellij will not identify a test class as a test, particularly for nested tests. But, I am able to right click on the individual classes and run them in Intellij.
Below is my hack of a gradle.build file that got things working in intellij (including what I commented out & added).
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0-M2'
}
}
repositories {
mavenCentral()
}
ext.junit4Version = '4.12'
ext.junitVintageVersion = '4.12.0-M2'
ext.junitPlatformVersion = '1.0.0-M12'
ext.junitJupiterVersion = '5.0.0-M2'
ext.junitPlatformConsoleVersion = '1.0.0-M2'
ext.log4JVersion = '2.5'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.junit.platform.gradle.plugin'
jar {
baseName = 'x2'
version = '1.0.0-SNAPSHOT'
}
compileTestJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
options.compilerArgs += '-parameters'
}
junitPlatform {
// platformVersion '1.0.0-SNAPSHOT'
engines {
include 'junit-jupiter', 'junit-vintage'
// exclude 'custom-engine'
}
tags {
// include 'fast'
// exclude 'slow'
}
// includeClassNamePattern '.*Test'
// enableStandardTestTask true
// reportsDir "build/test-results/junit-platform" // this is the default
// logManager 'org.apache.logging.log4j.jul.LogManager'
}
dependencies {
// JUnit Jupiter API and TestEngine implementation
testCompile("org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}")
testRuntime("org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}")
testCompile("org.junit.platform:junit-platform-console:${junitPlatformConsoleVersion}")
testRuntime("org.junit.platform:junit-platform-console:${junitPlatformConsoleVersion}")
// added to run via test suite
testCompile("org.junit.platform:junit-platform-runner:${junitPlatformConsoleVersion}")
testRuntime("org.junit.platform:junit-platform-runner:${junitPlatformConsoleVersion}")
// If you also want to support JUnit 3 and JUnit 4 tests
//testCompile("junit:junit:${junit4Version}")
//testRuntime("org.junit.vintage:junit-vintage-engine:${junitVintageVersion}")
// testRuntime("org.apache.logging.log4j:log4j-core:${log4JVersion}")
// testRuntime("org.apache.logging.log4j:log4j-jul:${log4JVersion}")
}
task wrapper(type: Wrapper) {
distributionUrl = 'https://services.gradle.org/distributions/gradle-2.14.1-bin.zip'
}
Hope this helps.