Skip to content

StepBuilder

annotation in io.proptastic

@interface StepBuilder

Generates typed steps for a stateful test from an interface of them: each abstract method is a step, named by the method, its arguments typed by its parameters. For @StepBuilder interface Banking, proptastic’s annotation processor writes two classes beside it:

  • BankingSteps, the steps: BankingSteps.steps(Accounts::new).deposit(people(), amounts()), a Steps whose every step calls that method on a state that implements Banking, then .when and .invariant as on any steps;
  • BankingStep, one step, for a pin: .example(deposit("alice", 1L), …) with import static bank.BankingStep.*, as a failure’s pin it: line writes it.

A value a step makes that later steps use is a Handle: @Handle("account") long open() keeps what it returns, deposit(@Handle("account") long account, long amount) draws one, and BankingStep.account(1) names the first in a pin, .example(open(), deposit(account(1), 1L)).

A renamed step, or one whose arguments change, then breaks the test and its pins when they’re compiled, not when they run. The processor runs when proptastic is on the annotation processor path: Gradle’s testAnnotationProcessor, or Maven’s annotationProcessorPaths.

Privacy