Skip to main content
Version: 6.0.0 (Unmaintained)

Builder

Builder is a sealed interface for constructing immutable Action instances.

public sealed interface Builder
permits Instance.Builder,
Parallel.Builder,
Repeat.Builder,
Scope.Builder,
Sequence.Builder,
Static.Builder,
Timeout.Builder {

Action build();
}

Design​

Each Action subtype that requires configuration exposes a corresponding Builder nested class. Callers configure the builder, then call build() to produce an immutable action snapshot. Builders are reusable — build() may be called multiple times.

Builder subtypes​

BuilderProducesDescription
Sequence.BuilderSequenceSequential execution; .child(action) adds children.
Parallel.BuilderParallelConcurrent execution; .parallelism(int) controls in-flight count.
Scope.BuilderScopeBefore-body-after with lifecycle guarantee.
Static.BuilderStaticBefore-body-after without fixture instance.
Instance.BuilderInstanceFixture instance lifecycle; .body(action) sets the body.
Repeat.BuilderRepeatExecutes child action N times.
Timeout.BuilderTimeoutExecutes child action with wall-clock deadline.

Usage​

Action action = Sequence.builder("flow")
.child(Step.of("step one", ctx -> stepOne()))
.child(Step.of("step two", ctx -> stepTwo()))
.build();

var result = Runner.defaultRunner().run(action);

Each action factory method returns a Builder:

Action scoped = Scope.builder("browser test")
.before(Step.of("start", ctx -> start()))
.body(Step.of("test", ctx -> test()))
.after(Step.of("stop", ctx -> stop()))
.build();

Action fixture = Instance.builder("user test", UserFixture::new)
.body(Step.of("verify", Context.withInstance(UserFixture.class, f -> f.verify())))
.build();

See Action for the Action sealed interface and its subtypes.