-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
java_test: make it work for multiple junit tests and non tests sources without Skylark wrapper and dependent library #2539
Comments
Reassigning to @kush-c who want to remove --legacy_bazel_java_test since this should be a blocker for the flag removal. |
Actually I was just trying to clean up code, as it thought it was deprecated. Assigning this back to you @iirina since I didn't anticipate this blocker, and I may not be working on this anytime soon. |
Sorry, the bot misinterpreted the commit message. Reopening this. |
I have something working in my fork of the scala rules and I'm trying to see if/how it can be generalized to being it's own rule.
|
@damienmg following our conversation I'll wait your update if you think this can be done outside of the team, right? If so I'll try to find volunteers. |
@ittaiz that works we would be happy to review your changes |
Is there an update on this issue? Either a built in way in bazel, or an official skylark wrapper to generate test suites? |
I have a solution in rules_scala which I want to pull out into a generic
solution.
It emulates maven's behavior of scanning the classes of the current
target's jar and runs all which fit the input prefixes/suffixes.
I think it's blocked though on having location expansion support runtime.
…On Fri, 15 Sep 2017 at 19:47 Paul Gross ***@***.***> wrote:
Is there an update on this issue? Either a built in way in bazel, or an
official skylark wrapper to generate test suites?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2539 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABUIFz2wvaQzjieFhSmPoSH3qSA__Xw4ks5siqoigaJpZM4MDLq->
.
|
Gerrit Code Review project extracted Bazlets repository. You can use its https://github.com/GerritCodeReview/bazlets/blob/master/tools/junit.bzl#L65-L73 |
Voicing my support of this. Using bazel after coming from Gradle feels like 2 steps forward 1 step back. It's debilitating trying to find what the "correct" way to do Java testing is in Bazel. If possible, could this be raised to P2? Lack of testing support is the #1 blocker for me moving to Bazel. |
@carl-mastrangelo thanks to mild pressure by @natansil we did some initial work to extract this mechanism from rules_scala. |
How about also providing some guidance on testing in Migrating from Maven to Bazel? That is the first place everyone looks. |
I would like to add that the suggestion to explicitly define tests in an |
An easy workaround is to add this to all non-test classes: /** Workaround for https://github.com/bazelbuild/bazel/issues/2539 */
@Test
public void emptyTest() {} |
I wanted to link to @davido's very helpful comment in #10036, since this issue seems to be where active discussion on this feature request is taking place. While I had previously been using # WORKSPACE
git_repository(
name = "google_bazel_common",
commit = "6db2b87d28f765f0064bc437bd489b432ec101b8",
remote = "git://github.com/google/bazel-common.git",
)
load("@google_bazel_common//:workspace_defs.bzl", "google_common_workspace_rules")
google_common_workspace_rules()
# BUILD
java_library (
name = "lib_src",
srcs = glob(["src/main/java/**/*.java"]),
resources = glob(["src/main/resources/**"]),
deps = DEPS
)
java_library (
name = "lib_test",
srcs = glob(["src/test/java/**/*.java"]),
deps = [":lib_src"] + DEPS_TEST
)
gen_java_tests(
name = "test_all",
srcs = glob(["src/test/java/**/*Test.java"]),
deps = [
":lib_src",
":lib_test",
],
) Hopefully this helps someone looking for a viable workaround! |
Is anyone working on this? |
Just to add another voice in support of this feature, it would prove very useful for large codebases with many tests, especially when porting from a system like Buck that already supports this. Specifically, there are two "workarounds" that currently show up in conversations about this, but both have downsides:
Looking through the source code, I saw that This is entirely a PoC, but thought I would share it to elicit some feedback on if this is a viable approach and, if not, why? Some obvious improvements are allowing tests to be passed in without having to split on Also, wasn't quite sure how to deal with the fact the current implementation expects a single name for the suite; currently just cobbled something in but a better solution might be to pass in the name of the |
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale. |
It would be nice to know what the current state of this is, as it is still an issue; however, I'm wondering if it would make sense to close this one and open a new issue under |
java_test
rule doesn't work as I would expect it should. I would expect to write this and provide mixed Junit tests and utility (also not tests classes) to thesrcs
glob.Buck version:
This doesn't work. Instead, I need this Skylark wrapper to generate JUnit Suites for me: [1]. Even then, it doesn't work because I must separate the utility library with non test sources from the JUnit test sources.
Bazel version:
[1] https://github.com/GerritCodeReview/gerrit/blob/master/tools/bzl/junit.bzl
The text was updated successfully, but these errors were encountered: