question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java_test: make it work for multiple junit tests and non tests sources without Skylark wrapper and dependent library

See original GitHub issue

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 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:open
  • Created 7 years ago
  • Reactions:8
  • Comments:17 (11 by maintainers)

github_iconTop GitHub Comments

7reactions
pgr0sscommented, Sep 15, 2017

Is there an update on this issue? Either a built in way in bazel, or an official skylark wrapper to generate test suites?

5reactions
carl-mastrangelocommented, Oct 15, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found