[Java] Add entry to run custom test using bazel (#26073)

Now we can run custom java tests by:

0. `cp testng_custom_template.xml testng_custom.xml`
1. Specify test class/method in `testng_custom.xml`
2. `bazel test //java:custom_test --test_output=streamed`
This commit is contained in:
Lixin Wei 2022-06-27 11:40:16 +08:00 committed by GitHub
parent db6f8a2f01
commit c4b9e9ffa5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 5 deletions

1
.gitignore vendored
View file

@ -163,6 +163,7 @@ java/**/.settings
java/**/.classpath java/**/.classpath
java/**/.project java/**/.project
java/runtime/native_dependencies/ java/runtime/native_dependencies/
java/testng_custom.xml
dependency-reduced-pom.xml dependency-reduced-pom.xml

View file

@ -177,11 +177,8 @@ define_java_module(
], ],
) )
java_binary( java_library(
name = "all_tests", name = "all_tests_lib",
args = ["java/testng.xml"],
data = ["testng.xml"],
main_class = "org.testng.TestNG",
runtime_deps = [ runtime_deps = [
":io_ray_ray_performance_test", ":io_ray_ray_performance_test",
":io_ray_ray_runtime_test", ":io_ray_ray_runtime_test",
@ -190,6 +187,39 @@ java_binary(
], ],
) )
java_test(
name = "all_tests",
args = ["java/testng.xml"],
data = [
"testng.xml",
":ray_java_pkg",
"//:ray_pkg",
],
main_class = "org.testng.TestNG",
tags = ["local"],
runtime_deps = [
":all_tests_lib",
],
)
# 0. `cp testng_custom_template.xml testng_custom.xml`
# 1. Specify test class/method in `testng_custom.xml`
# 2. `bazel test //java:custom_test --test_output=streamed`
java_test(
name = "custom_test",
args = ["java/testng_custom.xml"],
data = [
"testng_custom.xml",
":ray_java_pkg",
"//:ray_pkg",
],
main_class = "org.testng.TestNG",
tags = ["local"],
runtime_deps = [
":all_tests_lib",
],
)
# We'd better make resource files can be accessed from 3rd party library. # We'd better make resource files can be accessed from 3rd party library.
# More detail please see https://github.com/ray-project/ray/pull/21641. # More detail please see https://github.com/ray-project/ray/pull/21641.
java_proto_compile( java_proto_compile(

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="RAY suite" verbose="2" configfailurepolicy="continue">
<test name = "RAY test">
<classes>
<class name="io.ray.test.CrossLanguageInvocationTest">
<methods>
<include name="testPythonCallJavaFunction" />
</methods>
</class>
</classes>
</test>
<listeners>
<listener class-name="io.ray.test.RayAlterSuiteListener" />
<listener class-name="io.ray.test.TestProgressListener" />
<listener class-name="io.ray.test.SystemPropertyListener" />
</listeners>
</suite>