JUnit from TestRunner_deploy.jar takes precedence over other deps
Description of the problem / feature request / question:
It seems that java_test rule adds TestRunner_deploy.jar to the compile and run classpath. This entry is first on the list, unless a "real" JUnit jar is specified as a runtime dependency.
This makes it hard to use JUnit 4.12 features. They either don't compile (in sources for java_test) or fail at runtime, unless the runtime_deps trick is used. See the repro project below.
If possible, provide a minimal example to reproduce the problem:
https://github.com/benol/bazel-java-test-repro
Environment info
-
Operating System: Ubuntu
-
Bazel version (output of
bazel info release): release 0.4.0
This is a known issue. We've been working on removing some TestRunner's dependencies, aiming to removing all of them, including junit. However this won't happen in the near future, since there are more pressing issues to fix.
@kush-c is working on persistent test workers that may solve this problem, maybe he can give an opinion about this.
Removing those dependencies completely would of course be ideal, but it would be a good start if we made sure TestRunner_deploy.jar was at the end of the class path, so that the explicit JUnit dependency takes precedence. Would that be possible in the short term?
On Wed, Nov 30, 2016, 09:32 iirina [email protected] wrote:
This is a known issue. We've been working on removing some TestRunner's dependencies, aiming to removing all of them, including junit. However this won't happen in the near future, since there are more pressing issues to fix. @kush-c https://github.com/kush-c is working on persistent test workers that may solve this problem, maybe he can give an opinion about this.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bazelbuild/bazel/issues/2146#issuecomment-263825606, or mute the thread https://github.com/notifications/unsubscribe-auth/AAD9vxSOgUA6KZWWI2Qrt23HY1W8NNLkks5rDUKYgaJpZM4K-7oT .
@iirina is @benol's suggestion possible? if not maybe upgrade the the bundled junit to 4.12? All relevant workarounds until a more stable solution can come. This isn't blocking us right now since we're using our implementation of junit test (from rules_scala) but we hope to drop that one very soon thanks to the work you and @sdtwigg are doing.
Wondering if there's any progress on a workaround for this issue. It's not been too hard so far to limit ourselves to JUnit 4.10 features, but we keep having to "downgrade" tests to more complex expressions solely to be able to run them in Bazel.
(We're using junit_tests copied from Gerrit, recommended here: https://github.com/bazelbuild/rules_java/issues/330)
Has this issue been solved by the addition of Bazel's explicit_java_test_deps command line argument?
This just broke my IntelliJ: https://github.com/bazelbuild/intellij/issues/1641
I was using assertThrows, which apparently got added in JUnit 4.13, and Bazel is on 4.12.
Hi there! We're doing a clean up of old issues and will be closing this one. Please reopen if you’d like to discuss anything further. We’ll respond as soon as we have the bandwidth/resources to do so.