我们有测试依赖文件src/test/resources
根据Maven 标准目录布局。当测试类通过以下方式获取这些测试文件时,这些测试文件最终会出现在 JAR 和类路径中:Resources#asCharSource.
Bazel 中依赖测试文件并使它们出现在类路径中的首选方式是什么?
我的中有以下内容src/test/resources/BUILD
:
filegroup(
name = "test-deps",
testonly = 1,
srcs = glob(["*.txt"]),
visibility = ["//visibility:public"],
)
以及我的以下内容src/main/java/com/path/to/my/test/BUILD
:
java_test(
name = "MyTest",
srcs = ["MyTest.java"],
resources = ["//src/test/resources:test-deps"],
test_class = "com.path.to.my.test.MyTest",
deps = [
"//src/main/com/path/to/my/code",
"//:junit_junit",
],
)
这可行,但我不确定这是否是 Bazel 中最好的方法。