diff --git a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/ActualRunner.java b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/ActualRunner.java index 02c59774..31f7cd63 100644 --- a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/ActualRunner.java +++ b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/ActualRunner.java @@ -57,7 +57,7 @@ public boolean run(String testClassName) { FailFastExtension failFastExtension = new FailFastExtension(); LauncherConfig config = - LauncherConfig.builder() + getLauncherConfigBuilder() .addTestExecutionListeners(bazelJUnitXml, summary, failFastExtension) .addPostDiscoveryFilters(TestSharding.makeShardFilter()) .build(); @@ -79,6 +79,17 @@ public boolean run(String testClassName) { } } + /** Create and LauncherConfig.Builder instance for use in the launcher */ + protected LauncherConfig.Builder getLauncherConfigBuilder() { + return LauncherConfig.builder(); + } + + /** + * Creates a LauncherDiscoveryRequest for the test class provided from bazel + * + * @param testClassName the fqn of the test class provided from the test_class argument + * @return the LauncherDiscoveryRequest for the run + */ protected LauncherDiscoveryRequest getRequest(String testClassName) { final Class testClass; try { @@ -106,12 +117,17 @@ protected LauncherDiscoveryRequest getRequest(String testClassName) { .configurationParameter(LauncherConstants.CAPTURE_STDOUT_PROPERTY_NAME, "true") .configurationParameter( Constants.EXTENSIONS_AUTODETECTION_ENABLED_PROPERTY_NAME, "true") - .filters(getFilters().toArray(new Filter[0])); + .filters(getFilters()); return request.build(); } - protected List> getFilters() { + /** + * Returns an array of filters to filter tests for the run. This implementation returns filters + * constructed from bazel --test_filter option in addition to include/exclude arguments part of + * java_junit5_test + */ + protected Filter[] getFilters() { List> filters = new ArrayList<>(); String filter = System.getenv("TESTBRIDGE_TEST_ONLY"); @@ -142,7 +158,7 @@ protected List> getFilters() { filters.add(excludeEngines(excludeEngines)); } - return filters; + return filters.toArray(new Filter[0]); } /** diff --git a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/JUnit5Runner.java b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/JUnit5Runner.java index 17b4a8f2..5c7fa79a 100644 --- a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/JUnit5Runner.java +++ b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/JUnit5Runner.java @@ -52,6 +52,7 @@ public void run() { exit(systemExitToggle, 0); } + /** Returns an instance of RunsTest which handles creating and invoking the test runner */ protected RunsTest getRunner() throws ReflectiveOperationException { Constructor constructor = Class.forName(JUNIT5_RUNNER_CLASS).asSubclass(RunsTest.class).getConstructor();