java_test: make it work for multiple junit tests and non tests sources without Skylark wrapper and dependent library
See original GitHub issuejava_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 the srcs
glob.
Buck version:
java_test(
name = 'evict_cache_tests',
srcs = glob(['src/test/java/**/*.java']),
)
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:
load("//tools/bzl:junit.bzl", "junit_tests")
java_library(
name = "evict_test_utills",
srcs = glob([<non tests utility classes only>]),
)
junit_tests(
name = "evict_cache_tests",
srcs = glob(["src/test/java/**/*Test.java"]),# this would only pick test sources
deps = [":evict_test_utills"],
)
[1] https://github.com/GerritCodeReview/gerrit/blob/master/tools/bzl/junit.bzl
Issue Analytics
- State:
- Created 7 years ago
- Reactions:8
- Comments:17 (11 by maintainers)
Top Results From Across the Web
JUnit 5 tutorial - Learn how to write unit tests - Vogella.com
This tutorial explains unit testing with JUnit with the JUnit 5 framework (JUnit Jupiter). It explains the creation of JUnit 5 tests with ......
Read more >How to Write Effective Unit Tests in Java - Twilio
To avoid any confusion, the first example will demonstrate how to test some code without using any libraries at all; not even JUnit....
Read more >JUnit - Specify a test's dependency on other tests (without ...
Said libraries provide their own test runner, which supports their dependency mechanism. And both can be used alongside JUnit (without need ...
Read more >Testing | Bazel
There are several different approaches to testing Starlark code in Bazel. This page gathers the current best practices and frameworks by use ...
Read more >Diff - intellij - Google Git
This is required to build IJwB, # and run integration tests. new_http_archive( ... + # currently there's no Go Skylark API, with the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Is there an update on this issue? Either a built in way in bazel, or an official skylark wrapper to generate test suites?
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.