i am trying to make a Maven-built project build with Bazel. I struggle with getting the unit tests to pass because of abstact Classes name FooAbstractTest.java or AbstractFooTest.java. Several other build tools have tiher ignore rules by default or allow to specify such ignore rules.
I believe jUnit also allows to ignore classes but only since version 4.12.
Is there some obvious way to achieve this that I am missing? My current state is:
java_library(
name = "commons-math",
srcs = glob(["src/main/java/**/*.java"])
)
java_library(
name = "test_helpers",
srcs = glob(
["src/test/java/**/*.java"],
exclude = ["src/test/java/**/*Test.java"]
),
deps = [
':commons-math',
'@junit//jar',
'@hamcrest-all//jar',
],
)
java_test(
name = "commons-math-tests",
srcs = glob(["src/test/java/**/*Test.java"]),
deps = [
':commons-math',
':test_helpers',
'@junit//jar',
'@hamcrest-all//jar',
],
)
I guess my other alternatives are using @Ignore annotations or splitting up the tests into different subfolders (like src/test and src/testSupport).
Sorry, found a workaround myself:
java_library(
name = "test_helpers",
srcs = glob(
["src/test/java/**/*.java"]
),
deps = [
':commons-math',
'@junit//jar',
'@hamcrest-all//jar',
],
)
java_test(
name = "commons-math-tests",
srcs = glob(["src/test/java/**/*Test.java"],
exclude = ["src/test/java/**/*Abstract*Test.java"]),
resources = glob(["src/test/resource/**/*.*"]),
deps = [
':commons-math',
':test_helpers',
'@junit//jar',
'@hamcrest-all//jar',
],
)
Note this is not a clean solution, so it's not recommended to be copied. But it works for my purposes.
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/18b7e54b-9d74-4b89-b82f-766049f55462%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
IMO, one should generally not need to define both a java_library with tests and a java_test.
In this case I only do so because the two rules could not be unified in one with the tests still running.
I pointed to some cleaner alternatives earlier (like @Ignore), and there might also be other cleaner alternatives when structuring the build files differently.
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/45877231-d8ef-4027-a439-1f5566d49bd3%40googlegroups.com.