From 2bfa1d52031005a5ead4d92a9451c260d3878cc0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?L=C3=A9o=20Geoffroy?= Date: Tue, 20 Feb 2024 10:18:25 +0100 Subject: [PATCH] SONAR-21643 Add support for Junit5 --- build.gradle | 7 +++++++ sonar-core/build.gradle | 9 +++++++++ .../src/test/java/org/sonar/classloader/MaskTest.java | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e0162931140..819bfa4ed12 100644 --- a/build.gradle +++ b/build.gradle @@ -356,6 +356,13 @@ subprojects { dependency 'javax.servlet:javax.servlet-api:4.0.1' dependency 'javax.xml.bind:jaxb-api:2.3.1' dependency 'junit:junit:4.13.2' + // JUnit 5 + dependencySet(group: 'org.junit.jupiter', version: '5.10.2') { + entry 'junit-jupiter-api' + entry 'junit-jupiter-engine' + entry 'junit-jupiter-params' + entry 'junit-vintage-engine' + } dependency 'org.xmlunit:xmlunit-core:2.9.1' dependency 'org.xmlunit:xmlunit-matchers:2.9.1' dependency 'org.lz4:lz4-java:1.8.0' diff --git a/sonar-core/build.gradle b/sonar-core/build.gradle index 79045ab8c46..e68c4095e44 100644 --- a/sonar-core/build.gradle +++ b/sonar-core/build.gradle @@ -30,6 +30,7 @@ dependencies { testImplementation 'com.tngtech.java:junit-dataprovider' testImplementation 'junit:junit' testImplementation 'org.assertj:assertj-core' + testImplementation 'org.junit.jupiter:junit-jupiter-api' testImplementation 'org.hamcrest:hamcrest-core' testImplementation 'org.mockito:mockito-core' testImplementation 'org.simpleframework:simple' @@ -37,6 +38,9 @@ dependencies { testImplementation project(':sonar-testing-harness') testCompileOnly 'com.google.code.findbugs:jsr305' + + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' + testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' } // Used by sonar-db-core to run DB Unit Tests @@ -52,3 +56,8 @@ publishing { } } } + +test { + // Enabling the JUnit Platform (see https://github.com/junit-team/junit5-samples/tree/master/junit5-migration-gradle) + useJUnitPlatform() +} diff --git a/sonar-core/src/test/java/org/sonar/classloader/MaskTest.java b/sonar-core/src/test/java/org/sonar/classloader/MaskTest.java index abb793445ce..8868ab12089 100644 --- a/sonar-core/src/test/java/org/sonar/classloader/MaskTest.java +++ b/sonar-core/src/test/java/org/sonar/classloader/MaskTest.java @@ -19,7 +19,7 @@ */ package org.sonar.classloader; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; -- 2.39.5