Skip to content

Commit f9018c6

Browse files
bonigarciadiemol
andauthored
[java] Run tests on the JUnit Platform (JUnit 5) (#10752)
* [java] Use java_test_suite and from contrib_rule_jvm First step in the migration of the test codebase to JUnit 5 issue #10196 * [java] Manage JUnit 5 dependencies, using junit-vintage for existing tests Second step in the migration of the test codebase to JUnit 5 issue #10196 * [java] Move interface HasMagicNumbers to a separate class issue #10196 * [java] Include missing dependencies issue #10196 * [java] Include additional JUnit 5 dependencies issue #10196q * [java] Use JUnit 4 runner by default Since the existing tests are based on JUnit 4 issue #10196 * [java] Remove lint tests for contrib_rules_jvm macros Pull java_test and java_library from contrib_rules_jvm and not from the default packages issue #10196 * [java] Bump to contrib_rules_jvm version 0.3.0 * [java] Use spotbugs as linter from contrib_rules_jvm Co-authored-by: Diego Molina <diemol@users.noreply.github.com>
1 parent 7c92468 commit f9018c6

File tree

81 files changed

+702
-328
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+702
-328
lines changed

WORKSPACE

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,21 @@ load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")
130130

131131
rules_jvm_external_setup()
132132

133+
http_archive(
134+
name = "contrib_rules_jvm",
135+
sha256 = "79773625951a7a6dc0fc1636ef2388253b69a1e8109b34198c191953280648ab",
136+
strip_prefix = "rules_jvm-0.3.0",
137+
url = "https://github.com/bazel-contrib/rules_jvm/archive/v0.3.0.tar.gz",
138+
)
139+
140+
load("@contrib_rules_jvm//:repositories.bzl", "contrib_rules_jvm_deps")
141+
142+
contrib_rules_jvm_deps()
143+
144+
load("@contrib_rules_jvm//:setup.bzl", "contrib_rules_jvm_setup")
145+
146+
contrib_rules_jvm_setup()
147+
133148
load("//java:maven_deps.bzl", "selenium_java_deps")
134149

135150
selenium_java_deps()

java/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
load("@rules_jvm_external//:defs.bzl", "artifact")
2-
load("//java:defs.bzl", "spotbugs_config")
2+
load("@contrib_rules_jvm//java:defs.bzl", "spotbugs_config")
33

44
exports_files(
55
srcs = [
@@ -41,7 +41,7 @@ spotbugs_config(
4141
name = "spotbugs-config",
4242
effort = "default",
4343
exclude_filter = "spotbugs-excludes.xml",
44-
fail_on_warning = True,
44+
fail_on_warning = False,
4545
visibility = [
4646
"//visibility:public",
4747
],

java/defs.bzl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,16 @@ load("//java/private:library.bzl", _java_export = "java_export", _java_library =
99
load("//java/private:merge_jars.bzl", _merge_jars = "merge_jars")
1010
load("//java/private:module.bzl", _java_module = "java_module")
1111
load("//java/private:selenium_test.bzl", _selenium_test = "selenium_test")
12-
load("//java/private:spotbugs_config.bzl", _spotbugs_config = "spotbugs_config")
13-
load("//java/private:suite.bzl", _java_selenium_test_suite = "java_selenium_test_suite", _java_test_suite = "java_test_suite")
12+
load("//java/private:suite.bzl", _java_selenium_test_suite = "java_selenium_test_suite")
13+
load(
14+
"@contrib_rules_jvm//java:defs.bzl",
15+
_JUNIT5_DEPS = "JUNIT5_DEPS",
16+
_JUNIT5_VINTAGE_DEPS = "JUNIT5_VINTAGE_DEPS",
17+
_java_test_suite = "java_test_suite",
18+
)
19+
20+
def java_test_suite(name, runner = "junit4", **kwargs):
21+
_java_test_suite(name = name, runner = runner, **kwargs)
1422

1523
artifact = _artifact
1624
java_binary = _java_binary
@@ -21,8 +29,8 @@ java_library = _java_library
2129
java_module = _java_module
2230
java_selenium_test_suite = _java_selenium_test_suite
2331
java_test = _java_test
24-
java_test_suite = _java_test_suite
2532
javadoc = _javadoc
2633
merge_jars = _merge_jars
2734
selenium_test = _selenium_test
28-
spotbugs_config = _spotbugs_config
35+
JUNIT5_DEPS = _JUNIT5_DEPS
36+
JUNIT5_VINTAGE_DEPS = _JUNIT5_VINTAGE_DEPS

java/maven_deps.bzl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ load("@rules_jvm_external//:specs.bzl", "maven")
44
def selenium_java_deps():
55
netty_version = "4.1.77.Final"
66
opentelemetry_version = "1.14.0"
7+
junit_jupiter_version = "5.8.2"
8+
junit_platform_version = "1.8.2"
79

810
maven_install(
911
artifacts = [
@@ -66,6 +68,14 @@ def selenium_java_deps():
6668
"org.hamcrest:hamcrest-library",
6769
],
6870
),
71+
"org.junit.jupiter:junit-jupiter-api:%s" % junit_jupiter_version,
72+
"org.junit.jupiter:junit-jupiter-engine:%s" % junit_jupiter_version,
73+
"org.junit.jupiter:junit-jupiter-params:%s" % junit_jupiter_version,
74+
"org.junit.vintage:junit-vintage-engine:%s" % junit_jupiter_version,
75+
"org.junit.platform:junit-platform-launcher:%s" % junit_platform_version,
76+
"org.junit.platform:junit-platform-reporting:%s" % junit_platform_version,
77+
"org.junit.platform:junit-platform-commons:%s" % junit_platform_version,
78+
"org.junit.platform:junit-platform-engine:%s" % junit_platform_version,
6979
"net.bytebuddy:byte-buddy:1.12.10",
7080
"dev.failsafe:failsafe:3.2.4",
7181
"net.sourceforge.htmlunit:htmlunit-core-js:2.61.1",

java/maven_install.json

Lines changed: 472 additions & 2 deletions
Large diffs are not rendered by default.

java/private/library.bzl

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
load("@apple_rules_lint//lint:defs.bzl", "get_lint_config")
22
load(
3-
"@rules_java//java:defs.bzl",
3+
"@contrib_rules_jvm//java:defs.bzl",
4+
"spotbugs_test",
45
_java_library = "java_library",
56
_java_test = "java_test",
67
)
78
load(":export.bzl", _java_export = "java_export")
8-
load(":spotbugs.bzl", "spotbugs_test")
99

1010
def add_lint_tests(name, **kwargs):
1111
srcs = kwargs.get("srcs", [])
@@ -29,14 +29,6 @@ def add_lint_tests(name, **kwargs):
2929
timeout = "moderate",
3030
)
3131

32-
def java_export(name, **kwargs):
33-
add_lint_tests(name, **kwargs)
34-
_java_export(name = name, **kwargs)
35-
36-
def java_library(name, **kwargs):
37-
add_lint_tests(name, **kwargs)
38-
_java_library(name = name, **kwargs)
39-
40-
def java_test(name, **kwargs):
41-
add_lint_tests(name, **kwargs)
42-
_java_test(name = name, **kwargs)
32+
java_export = _java_export
33+
java_library = _java_library
34+
java_test = _java_test

java/private/spotbugs.bzl

Lines changed: 0 additions & 103 deletions
This file was deleted.

java/private/spotbugs_config.bzl

Lines changed: 0 additions & 38 deletions
This file was deleted.

java/src/com/thoughtworks/selenium/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
load("@rules_jvm_external//:defs.bzl", "artifact")
2-
load("//java:defs.bzl", "java_library")
2+
load("//java:defs.bzl", "JUNIT5_VINTAGE_DEPS", "java_library")
33

44
java_library(
55
name = "api",
@@ -40,7 +40,7 @@ java_library(
4040
"//java/src/org/openqa/selenium:core",
4141
artifact("junit:junit"),
4242
artifact("org.testng:testng"),
43-
],
43+
] + JUNIT5_VINTAGE_DEPS,
4444
)
4545

4646
java_library(

java/src/com/thoughtworks/selenium/condition/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
load("@rules_jvm_external//:defs.bzl", "artifact")
2-
load("//java:defs.bzl", "java_library")
2+
load("//java:defs.bzl", "JUNIT5_VINTAGE_DEPS", "java_library")
33

44
java_library(
55
name = "condition",
@@ -10,5 +10,5 @@ java_library(
1010
deps = [
1111
"//java/src/com/thoughtworks/selenium:api",
1212
artifact("junit:junit"),
13-
],
13+
] + JUNIT5_VINTAGE_DEPS,
1414
)

0 commit comments

Comments
 (0)