{"id":19928494,"url":"https://github.com/dinowernli/bazel-junit-autotest","last_synced_at":"2025-05-03T10:31:10.226Z","repository":{"id":46456403,"uuid":"96674606","full_name":"dinowernli/bazel-junit-autotest","owner":"dinowernli","description":"A JUnit test runner which auto-detects tests. Intended for use with Bazel.","archived":false,"fork":false,"pushed_at":"2021-10-11T09:58:49.000Z","size":23,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-07T14:14:32.116Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dinowernli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-09T09:39:36.000Z","updated_at":"2021-10-11T09:55:14.000Z","dependencies_parsed_at":"2022-08-02T19:01:31.624Z","dependency_job_id":null,"html_url":"https://github.com/dinowernli/bazel-junit-autotest","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinowernli%2Fbazel-junit-autotest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinowernli%2Fbazel-junit-autotest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinowernli%2Fbazel-junit-autotest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinowernli%2Fbazel-junit-autotest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dinowernli","download_url":"https://codeload.github.com/dinowernli/bazel-junit-autotest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252178678,"owners_count":21707038,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T22:37:25.908Z","updated_at":"2025-05-03T10:31:09.877Z","avatar_url":"https://github.com/dinowernli.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bazel-junit-autotest\n\nA [JUnit](http://junit.org/junit4/) test runner which auto-detects tests. Intended for use with [Bazel](https://bazel.build/).\n\n## Setup\n\nIn order to use autotest, first import the repo into your `WORKSPACE` file:\n\n```python\ngit_repository(\n  name = \"autotest\",\n  remote = \"https://github.com/dinowernli/bazel-junit-autotest.git\",\n  tag = \"v0.0.1\",\n)\n```\n\nIf you are not already importing the JUnit library jars, you can configure autotest by adding the following to your `WORKSPACE` file:\n\n```python\nload(\"@autotest//bzl:autotest.bzl\", \"autotest_junit_repo\")\nautotest_junit_repo(autotest_workspace=\"@autotest\")\n```\nAlternatively, if you do already have the JUnit library jars available under a target called `//third_party/junit`, you can configure autotest by adding the following:\n\n```python\nload(\"@autotest//bzl:autotest.bzl\", \"autotest_junit_repo\")\nautotest_junit_repo(junit_jar = \"//third_party/junit\", autotest_workspace=\"@autotest\")\n```\n\n## Writing tests\n\nInside your `BUILD` file, add:\n\n```python\nload(\"@autotest//bzl:autotest.bzl\", \"auto_java_test\")\n```\n\nThen, to declare a test, use `auto_java_test` as a drop-in replacement for the native `java_test`:\n\n```python\nauto_java_test(\n  name = \"tests\",\n  srcs = glob(['*.java']),\n  size = \"small\",\n)\n```\n\nThe test runner will then scan the sources for types annotated with `@TestClass`, e.g.,\n\n```java\nimport me.dinowernli.junit.TestClass;\nimport org.junit.Test;\n\n@TestClass\npublic class SomeTestClass {\n  @Test\n  public void testSomething() {\n    // ...\n  }\n}\n```\n\n## Scan depth\n\nBy default, only first entry of the classpath is scanned for annotated classes. If you want to scan more entries, you can pass a `test_arg`, e.g.,\n\n```\nbazel test //foo/bar:tests --test_arg=--scan_depth=7\n```\n\n\n## Usage examples\n\nFor real-life examples, check out the [polyglot](https://github.com/grpc-ecosystem/polyglot/blob/master/src/test/java/me/dinowernli/grpc/polyglot/grpc/CompositeStreamObserverTest.java#L18) repo.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdinowernli%2Fbazel-junit-autotest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdinowernli%2Fbazel-junit-autotest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdinowernli%2Fbazel-junit-autotest/lists"}