Skip to content

Commit e6a1bbd

Browse files
committed
Support JUnit 5 alongside Junit 4
Signed-off-by: Daniel Widdis <widdis@gmail.com>
1 parent 0ffed5e commit e6a1bbd

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1212
- Added ability to retrieve value from DocValues in a flat_object filed([#16802](https://github.com/opensearch-project/OpenSearch/pull/16802))
1313
- Improve performace of NumericTermAggregation by avoiding unnecessary sorting([#17252](https://github.com/opensearch-project/OpenSearch/pull/17252))
1414
- [Rule Based Auto-tagging] Add in-memory attribute value store ([#17342](https://github.com/opensearch-project/OpenSearch/pull/17342))
15+
- Enable JUnit 5 usage in test framework ([#17475](https://github.com/opensearch-project/OpenSearch/pull/17475))
1516

1617
### Dependencies
1718
- Bump `org.awaitility:awaitility` from 4.2.0 to 4.3.0 ([#17230](https://github.com/opensearch-project/OpenSearch/pull/17230), [#17439](https://github.com/opensearch-project/OpenSearch/pull/17439))

gradle/libs.versions.toml

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ bouncycastle="1.78"
6262
# test dependencies
6363
randomizedrunner = "2.7.1"
6464
junit = "4.13.2"
65+
junit5 = "5.12.0"
66+
junitplatform = "1.12.0"
6567
hamcrest = "2.1"
6668
mockito = "5.14.2"
6769
objenesis = "3.3"

test/framework/build.gradle

+20
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ dependencies {
5353
api "org.bouncycastle:bcpkix-jdk18on:${versions.bouncycastle}"
5454
api "org.bouncycastle:bcutil-jdk18on:${versions.bouncycastle}"
5555

56+
// Allow usage of JUnit 5
57+
api "org.junit.jupiter:junit-jupiter-api:${versions.junit5}"
58+
runtimeOnly "org.junit.jupiter:junit-jupiter-engine:${versions.junit5}"
59+
// Maintain Junit 4 compatibility
60+
runtimeOnly "org.junit.platform:junit-platform-commons:${versions.junitplatform}"
61+
runtimeOnly "org.junit.platform:junit-platform-engine:${versions.junitplatform}"
62+
testRuntimeOnly "org.junit.platform:junit-platform-launcher:${versions.junitplatform}"
63+
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:${versions.junit5}") {
64+
exclude group: 'junit', module: 'junit'
65+
}
5666
annotationProcessor "org.apache.logging.log4j:log4j-core:${versions.log4j}"
5767
}
5868

@@ -75,6 +85,13 @@ thirdPartyAudit.ignoreMissingClasses(
7585
// classes are missing
7686
'javax.servlet.ServletContextEvent',
7787
'javax.servlet.ServletContextListener',
88+
'kotlin.Unit',
89+
'kotlin.collections.ArraysKt',
90+
'kotlin.collections.CollectionsKt',
91+
'kotlin.jvm.functions.Function0',
92+
'kotlin.jvm.functions.Function1',
93+
'kotlin.jvm.internal.Intrinsics',
94+
'kotlin.jvm.internal.Lambda',
7895
'org.apache.avalon.framework.logger.Logger',
7996
'org.apache.log.Hierarchy',
8097
'org.apache.log.Logger',
@@ -83,6 +100,7 @@ thirdPartyAudit.ignoreMissingClasses(
83100
'org.apache.log4j.Priority',
84101
'org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher',
85102
'org.opentest4j.AssertionFailedError',
103+
'org.opentest4j.TestAbortedException',
86104
'net.bytebuddy.agent.ByteBuddyAgent',
87105
'net.bytebuddy.agent.Installer'
88106
)
@@ -93,6 +111,8 @@ thirdPartyAudit.ignoreViolations(
93111
)
94112

95113
test {
114+
useJUnitPlatform()
115+
96116
systemProperty 'tests.gradle_index_compat_versions', BuildParams.bwcVersions.indexCompatible.join(',')
97117
systemProperty 'tests.gradle_wire_compat_versions', BuildParams.bwcVersions.wireCompatible.join(',')
98118
systemProperty 'tests.gradle_unreleased_versions', BuildParams.bwcVersions.unreleased.join(',')

0 commit comments

Comments
 (0)