// WithStep creates a context where a prefix is added to all errors and log // messages, similar to how errors are wrapped. This can be nested, leaving a // trail of "bread crumbs" that help figure out where in a test some problem // occurred or why some log output gets written: // // ERROR: bake cake: set heat for baking: oven not found // // The string should describe the operation that is about to happen ("starting // the controller", "list items") or what is being operated on ("HTTP server"). // Multiple different prefixes get concatenated with a colon. func WithStep(tCtx TContext, what string) TContext { … } // Step is useful when the context with the step information is // used more than once: // // ktesting.Step(tCtx, "step 1", func(tCtx ktesting.TContext) { // tCtx.Log(...) // if (... ) { // tCtx.Failf(...) // } // )} // // Inside the callback, the tCtx variable is the one where the step // has been added. This avoids the need to introduce multiple different // context variables and risk of using the wrong one. func Step(tCtx TContext, what string, cb func(tCtx TContext)) { … } type stepContext … func (sCtx *stepContext) Log(args ...any) { … } func (sCtx *stepContext) Logf(format string, args ...any) { … } func (sCtx *stepContext) Error(args ...any) { … } func (sCtx *stepContext) Errorf(format string, args ...any) { … } func (sCtx *stepContext) Fatal(args ...any) { … } func (sCtx *stepContext) Fatalf(format string, args ...any) { … } // Value intercepts a search for the special "GINKGO_SPEC_CONTEXT". func (sCtx *stepContext) Value(key any) any { … } type stepReporter … var _ … func (s *stepReporter) AttachProgressReporter(reporter func() string) func() { … }