Documentation
¶
Overview ¶
Package bdd runs Gherkin feature files against a project's .http requests with a fixed step vocabulary, using godog embedded in the binary.
Index ¶
Constants ¶
const ( ExitPassed = runner.ExitOK ExitFailed = runner.ExitAssert ExitUsage = runner.ExitUsage ExitTransport = runner.ExitTransport )
Exit codes from Run, aligned with the rest of apic.
Variables ¶
var Formats = []string{"pretty", "progress", "cucumber", "junit"}
Formats lists the accepted --format values.
var Vocabulary = []struct{ Pattern, Purpose string }{
{`the environment is "<name>"`, "switch the scenario to another environment"},
{`the variable "<name>" is "<value>"`, "set a variable for later steps"},
{`the variables:` + " (table name | value)", "set several variables"},
{`I run "<request>"`, "send a request by id; fails if its # @assert or # @capture fail"},
{`I run "<request>" with:` + " (table name | value)", "send a request with variables"},
{`I run the file "<file.http>"`, "send every request in a file, stopping at the first failure"},
{`the response status is <n>` + " / is not <n>", "status code"},
{`the response is successful` + " / a client error / a server error", "2xx / 4xx / 5xx"},
{`the response body "<path>" is "<value>"`, `also: is not, contains, starts with, ends with, matches; <path> like $.items[0].id`},
{`the response header "<name>" is "<value>"`, "same operators as for the body"},
{`the response body "<path>" exists` + " / does not exist", "presence of a value"},
{`the response body is:` + " (doc string)", "semantic JSON equality"},
{`the response body contains:` + " (doc string)", "JSON subset match"},
{`the response time is under <n> ms`, "round-trip time"},
{`I capture the response body "<path>" as "<name>"`, "store a value; also: header"},
}
Vocabulary documents the built-in steps for `apic test --steps` and the docs.
Functions ¶
func FeatureFiles ¶
FeatureFiles lists every .feature file the run would read, after the same root checks as the run itself. Callers use it to protect inputs.
Types ¶
type Config ¶
type Config struct {
Project *project.Project
Env string
Vars map[string]string
UseSession bool // read and write .apic/session.json instead of an isolated in-memory session
Timeout time.Duration
Insecure bool
Redact bool
Stderr io.Writer
// contains filtered or unexported fields
}
Config is shared by every scenario in a run.
type Failure ¶
type Failure struct {
Feature string `json:"feature"`
Scenario string `json:"scenario"`
Step string `json:"step"`
Status string `json:"status"`
Error string `json:"error,omitempty"`
}
Failure describes one failed or undefined step.
type Options ¶
type Options struct {
Config
Paths []string // feature files or directories; relative paths resolve against the project root
Features []godog.Feature // in-memory features (tests and MCP); used when Paths is empty
Format string // one of Formats; default pretty
Output io.Writer // report destination; default os.Stdout
Tags string // godog tag expression, e.g. "@smoke && ~@slow"
StopOnFailure bool
NoColors bool
}
Options controls one run.
type Summary ¶
type Summary struct {
OK bool `json:"ok"` // no scenario failed; check Scenarios for how many ran
Scenarios int `json:"scenarios"`
Passed int `json:"passed"`
Failed int `json:"failed"`
Skipped int `json:"skipped"` // not run, e.g. after --stop-on-failure
Undefined int `json:"undefined"`
Failures []Failure `json:"failures,omitempty"`
}
Summary is the machine-readable outcome of a run, derived from the cucumber JSON report.
func RunSummary ¶
RunSummary runs with the cucumber formatter into memory and returns the parsed summary plus the raw report. Used by MCP and tests. When a usage or transport error ends the run, the summary of what ran is still returned alongside the error whenever a report was produced.