Annotation Interface DisableInvocationSharding
@ParameterizedTest, @RepeatedTest,
@ClusterTest, or any other @TestTemplate-based test) out of invocation-level
Bazel test sharding.
By default, every test template method has its invocations distributed individually and
deterministically across Bazel test shards: the runner's shard filter (patched via
tools-bazel/contrib_rules_jvm_invocation_sharding.patch) keeps the method in every
shard, and an execution condition in the runner then disables the invocations the current
shard does not own, reporting them as skipped. This annotation reverses that: the runner's
shard filter instead hash-assigns the whole method to a single shard, exactly as it does for
plain @Test methods and as every method behaved before invocation sharding existed. All
of the method's invocations then run together, serially, in that one shard.
Use this when a test template method cannot tolerate having its invocations distributed across separate shard JVMs:
- The argument provider's invocation order or count is not guaranteed to be identical in
every shard JVM, for example because it depends on randomness, or because it iterates over a
collection whose order is salted per JVM (e.g.
Set.of(...)). Invocation ownership is computed independently in each shard from the invocation's ordinal, so providers must yield the same invocations in the same order everywhere or invocations can run twice or not at all. - Invocations of the method share mutable state with each other (e.g. fields set up once and reused across invocations), so they must keep running together in one JVM.
The annotation must be placed directly on the test class or test method; it is not detected when used as a meta-annotation. Class-level placement applies to all template methods of the class and is inherited by subclasses.