Skip to content

Commit

Permalink
Add docs and add more extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-mcnamara committed Aug 9, 2024
1 parent 2495f44 commit dcf06e6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 {
Expand Down Expand Up @@ -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<Filter<?>> 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<Filter<?>> filters = new ArrayList<>();

String filter = System.getenv("TESTBRIDGE_TEST_ONLY");
Expand Down Expand Up @@ -142,7 +158,7 @@ protected List<Filter<?>> getFilters() {
filters.add(excludeEngines(excludeEngines));
}

return filters;
return filters.toArray(new Filter[0]);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<? extends RunsTest> constructor =
Class.forName(JUNIT5_RUNNER_CLASS).asSubclass(RunsTest.class).getConstructor();
Expand Down

0 comments on commit dcf06e6

Please sign in to comment.