Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit 0581913

Browse files
committed
Use Gradle native support for JUnit 5
1 parent a1a3084 commit 0581913

File tree

2 files changed

+7
-82
lines changed

2 files changed

+7
-82
lines changed

build.gradle

Lines changed: 7 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ buildscript {
2020
}
2121
dependencies {
2222
classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.11',
23-
'org.springframework.build.gradle:propdeps-plugin:0.0.7',
24-
'io.spring.gradle:spring-io-plugin:0.0.4.RELEASE',
25-
'org.junit.platform:junit-platform-gradle-plugin:1.0.0'
23+
'io.spring.gradle:propdeps-plugin:0.0.9.RELEASE'
2624
}
2725
}
2826
plugins {
@@ -83,7 +81,6 @@ configure(allprojects) { project ->
8381
apply plugin: 'idea'
8482
apply plugin: 'propdeps'
8583
apply plugin: 'java'
86-
apply plugin: 'org.junit.platform.gradle.plugin'
8784

8885
sourceCompatibility = targetCompatibility = 1.8
8986

@@ -107,49 +104,6 @@ configure(allprojects) { project ->
107104
"-Xlint:-rawtypes" // TODO enable and fix warnings
108105
]
109106

110-
junitPlatform {
111-
filters {
112-
includeClassNamePattern '.*Tests'
113-
}
114-
// store test results where Bamboo expects them or the build will fail
115-
reportsDir file('build/test-results/test')
116-
}
117-
118-
// to generate HTML test reports
119-
// from https://stackoverflow.com/questions/39444908/how-to-create-an-html-report-for-junit-5-tests/39455463#39455463
120-
configurations {
121-
junitXmlToHtml
122-
}
123-
124-
task generateHtmlTestReports {
125-
doLast {
126-
def reportsDir = new File(buildDir, 'reports/tests/test')
127-
reportsDir.mkdirs()
128-
129-
ant.taskdef(
130-
name: 'junitReport',
131-
classname: 'org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator',
132-
classpath: configurations.junitXmlToHtml.asPath
133-
)
134-
135-
ant.junitReport(todir: "$buildDir/test-results/test", tofile: "aggregated-test-results.xml") {
136-
fileset(dir: "$buildDir/test-results/test")
137-
report(format: 'frames', todir: reportsDir)
138-
}
139-
}
140-
}
141-
142-
afterEvaluate {
143-
def junitPlatformTestTask = tasks.getByName('junitPlatformTest')
144-
generateHtmlTestReports.dependsOn(junitPlatformTestTask)
145-
test.dependsOn(generateHtmlTestReports)
146-
147-
// not related to HTML test reports
148-
// to launch rabbitmqctl, to close connections for connection recovery tests
149-
junitPlatformTestTask.systemProperty 'rabbitmqctl.bin', System.getProperty('rabbitmqctl.bin') ?: 'sudo rabbitmqctl'
150-
}
151-
// end of HTML test reports
152-
153107
jacocoTestReport {
154108
dependsOn test
155109
sourceSets sourceSets.main
@@ -169,50 +123,16 @@ configure(allprojects) { project ->
169123
testCompile("org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}")
170124
testCompile("org.junit.jupiter:junit-jupiter-params:${junitJupiterVersion}")
171125
testRuntime("org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}")
172-
// Only needed to run tests in an (IntelliJ) IDE(A) that bundles an older version
173-
testRuntime("org.junit.platform:junit-platform-launcher:${junitPlatformVersion}")
174126

175127
testCompile "io.projectreactor:reactor-test:$reactorCoreVersion"
176128
testCompile "org.mockito:mockito-core:$mockitoVersion"
177129
testRuntime "org.slf4j:jcl-over-slf4j:$slf4jVersion"
178130
testRuntime "org.slf4j:slf4j-api:$slf4jVersion"
179131
testRuntime "ch.qos.logback:logback-classic:$logbackVersion"
180-
181-
// to generate HTML test reports
182-
junitXmlToHtml 'org.apache.ant:ant-junit:1.9.7'
183-
}
184-
185-
project.tasks.withType(Test).all {
186-
systemProperty("java.awt.headless", "true")
187-
systemProperty("reactor.trace.cancel", "true")
188-
systemProperty("reactor.trace.nocapacity", "true")
189-
systemProperty("testGroups", project.properties.get("testGroups"))
190-
191-
scanForTestClasses = false
192-
include '**/*Tests.*'
193-
include '**/*Spec.*'
194-
exclude '**/*Abstract*.*'
195132
}
196133

197134
// force test runs even when there are no test changes
198135
test.outputs.upToDateWhen { false }
199-
200-
if (project.hasProperty('platformVersion')) {
201-
apply plugin: 'spring-io'
202-
203-
repositories {
204-
maven { url 'http://repo.spring.io/libs-snapshot' }
205-
}
206-
207-
dependencyManagement {
208-
springIoTestRuntime {
209-
imports {
210-
mavenBom "io.spring.platform:platform-bom:$platformVersion"
211-
}
212-
}
213-
}
214-
}
215-
216136
}
217137

218138
configure(rootProject) {
@@ -226,6 +146,11 @@ configure(rootProject) {
226146
}
227147
}
228148

149+
test {
150+
useJUnitPlatform()
151+
systemProperty 'rabbitmqctl.bin', System.getProperty('rabbitmqctl.bin') ?: 'sudo rabbitmqctl'
152+
}
153+
229154
artifacts {
230155
archives sourcesJar
231156
archives javadocJar
@@ -261,6 +186,7 @@ project(':reactor-rabbitmq-samples') {
261186
}
262187

263188
test {
189+
useJUnitPlatform()
264190
jacoco {
265191
enabled = false
266192
}

reactor-rabbitmq-samples/src/test/java/reactor/rabbitmq/samples/SamplesTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package reactor.rabbitmq.samples;
1818

19-
import org.junit.jupiter.api.Assertions;
2019
import org.junit.jupiter.api.Test;
2120

2221
import java.util.concurrent.CountDownLatch;

0 commit comments

Comments
 (0)