-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Macro junit_tests compiles and runs JUnit 5 tests.
- Loading branch information
Showing
4 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# junit_tests | ||
|
||
```bazel | ||
junit_tests(name, **kwargs) | ||
``` | ||
|
||
Compiles and runs JUnit 5 tests. | ||
|
||
The arguments are the same as for [`java_test`](https://bazel.build/reference/be/java#java_test). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
load("//java/private:executable_jar.bzl", _executable_jar = "executable_jar") | ||
load("//java/private:javadoc.bzl", _javadoc = "javadoc") | ||
load("//java/private:junit_tests.bzl", _junit_tests = "junit_tests") | ||
|
||
executable_jar = _executable_jar | ||
javadoc = _javadoc | ||
junit_tests = _junit_tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
_FORBIDDEN_ARGUMENTS = [ | ||
"args", | ||
"main_class", | ||
"use_testrunner", | ||
] | ||
|
||
def junit_tests(name, **kwargs): | ||
for argument in _FORBIDDEN_ARGUMENTS: | ||
if argument in kwargs: | ||
fail("Forbidden argument: {}.".format(argument)) | ||
|
||
if native.package_name(): | ||
jar = "{}/{}.jar".format(native.package_name(), name) | ||
else: | ||
jar = "{}.jar".format(name) | ||
|
||
native.java_test( | ||
name = name, | ||
main_class = "extrarulesjava.testrunner.TestRunner", | ||
use_testrunner = False, | ||
runtime_deps = kwargs.pop("runtime_deps", []) + [ | ||
"@extra_rules_java//test-runner", | ||
], | ||
args = [ | ||
jar, | ||
], | ||
**kwargs, | ||
) |