Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Junit 5 gradle plugin not found

Try to use junit 5 with gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0'
    }
}

apply plugin: 'java-library'
apply plugin: 'org.junit.platform.gradle.plugin'
...

Error:

Plugin with id 'org.junit.platform.gradle.plugin' not found.

Gradle version 4.0. What is wrong?

like image 799
eastwater Avatar asked Sep 28 '17 16:09

eastwater


People also ask

What is JUnit Jupiter?

JUnit Jupiter is the combination of the programming model and extension model for writing tests and extensions in JUnit 5. The Jupiter sub-project provides a TestEngine for running Jupiter based tests on the platform. JUnit Vintage provides a TestEngine for running JUnit 3 and JUnit 4 based tests on the platform.

What is the use of useJUnitPlatform?

Specifies that JUnit Platform (a.k.a. JUnit 5) should be used to execute the tests. To configure JUnit platform specific options, see #useJUnitPlatform(Action) . Specifies that JUnit Platform (a.k.a. JUnit 5) should be used to execute the tests, configuring JUnit platform specific options.


1 Answers

You have to include a repositories section outside the buildscript block as well:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0'
    }
}

apply plugin: 'java-library'
apply plugin: 'org.junit.platform.gradle.plugin'

repositories {
    mavenCentral()
}
like image 171
Sam Brannen Avatar answered Oct 08 '22 00:10

Sam Brannen