bdd

package
v0.57.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertProviderCapabilitiesMatchRegistration added in v0.50.0

func AssertProviderCapabilitiesMatchRegistration(t strictIaCT, provider any, grpcSrv *grpc.Server)

AssertProviderCapabilitiesMatchRegistration asserts that every typed IaC gRPC service interface satisfied by provider's Go type IS registered on grpcSrv, AND no IaC service is registered that the provider's Go type does NOT satisfy. Reports specific missing / extra service names so test failures point at the exact omission.

Per cycle 4 of the strict-contracts force-cutover design (belt-and- braces): the canonical registration path is sdk.RegisterAllIaCProviderServices, which uses Go type-assertion to auto-detect every interface and cannot omit a registration. The per-service Register* helpers are still exposed for advanced use cases (e.g., a plugin that registers a different Go type per optional service); this helper is the test-time guard that catches the manual-registration omission failure mode.

The provider parameter is the live Go provider implementation (typically a *DOProvider or test stub). The grpcSrv parameter is the gRPC server with the plugin's service registrations on it (typically the result of grpc.NewServer() + RegisterAllIaCProviderServices, or — for the failure case this guard catches — a server with manual per-service registrations).

Provider MUST satisfy pb.IaCProviderRequiredServer at minimum; if not, the helper reports a fatal-class failure naming the missing required interface (a broken fixture, not a runtime issue).

func RunFeatures

func RunFeatures(t *testing.T, path string, opts ...Option)

RunFeatures runs all Gherkin feature files at path using the pre-built step definitions. Each scenario gets a fresh ScenarioContext and wftest.Harness so scenarios are fully isolated.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config holds configuration for a BDD test run.

type CoverageReport

type CoverageReport struct {
	TotalPipelines       int
	CoveredPipelines     []PipelineCoverageEntry
	UncoveredPipelines   []string
	TotalScenarios       int
	ImplementedScenarios int // scenarios that reference a known pipeline
	PassingScenarios     int // filled in by test runner, not static analysis
	PendingScenarios     int // filled in by test runner, not static analysis
	UndefinedScenarios   int // TotalScenarios - ImplementedScenarios
}

CoverageReport summarises pipeline and scenario coverage from static analysis. PassingScenarios and PendingScenarios require a live test run; they are zero when returned by CalculateCoverage (static only).

func CalculateCoverage

func CalculateCoverage(configPath, featureDir string) (*CoverageReport, error)

CalculateCoverage performs static analysis: parses configPath for pipeline definitions and walks featureDir for .feature files. Returns a CoverageReport showing which pipelines are exercised by BDD scenarios.

type Option

type Option func(*Config)

Option configures a BDD test run.

func Strict

func Strict() Option

Strict makes the runner fail on undefined or pending steps.

func WithConfig

func WithConfig(path string) Option

WithConfig sets a default config file path applied to every scenario's harness.

func WithMockStep

func WithMockStep(name string, handler wftest.StepHandler) Option

WithMockStep registers a mock step handler applied to every scenario's harness.

func WithYAML

func WithYAML(yaml string) Option

WithYAML sets default inline YAML applied to every scenario's harness.

type PipelineCoverageEntry

type PipelineCoverageEntry struct {
	Pipeline    string
	FeatureFile string
	Line        int
	Via         string // "tag" or "route"
}

PipelineCoverageEntry describes a .feature file reference to a pipeline.

type ScenarioContext

type ScenarioContext struct {
	// contains filtered or unexported fields
}

ScenarioContext holds state for a single Gherkin scenario. A fresh ScenarioContext is created for each scenario. Harness creation is deferred until the first "When" action step so that all "Given" step options (YAML config, mocks, state seeds) are accumulated first and applied together when the harness is built.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL