Documentation
¶
Overview ¶
Package qualflare is the author-facing metadata API for the Qualflare Go reporter.
func TestCheckout(t *testing.T) {
qualflare.Label(t, "feature", "checkout")
qualflare.Tag(t, "smoke")
qualflare.Step(t, "add to cart", func() {
qualflare.Parameter(t, "sku", "widget")
})
}
Every call takes a testing.TB. Go has no goroutine-local storage, so the explicit tb is the only reliable handle on which test is running -- and it dissolves a whole class of problem the sibling reporters had to engineer around: metadata emitted outside a test is a COMPILE error here, not a runtime rule, because there is no tb to pass.
Nothing in this package can fail a test. Every function returns nothing, and the one call into testing.TB is guarded. A metadata problem must never be the reason somebody's suite goes red.
The results themselves do not come from here. Go has no per-test hook and TestMain sees only an exit code, so a library alone can never observe every test; the qualflare-go binary reads `go test -json` for that. This package only enriches.
Index ¶
- Constants
- func Attach(tb testing.TB, name string, data []byte, mimeType string)
- func AttachText(tb testing.TB, name, text, mimeType string)
- func Description(tb testing.TB, text string)
- func Enabled() bool
- func Label(tb testing.TB, name, value string)
- func Link(tb testing.TB, url, linkType, name string)
- func MaskedParameter(tb testing.TB, name string)
- func Parameter(tb testing.TB, name, value string)
- func Priority(tb testing.TB, level string)
- func Step(tb testing.TB, name string, fn func())
- func Tag(tb testing.TB, tags ...string)
Constants ¶
const ( EnvEnable = "QUALFLARE_GO" EnvSpill = "QUALFLARE_GO_SPILL" )
Environment variables the library reads.
const ( PriorityLow = "low" PriorityMedium = "medium" PriorityHigh = "high" PriorityCritical = "critical" )
Priority levels, matching the wire contract's vocabulary.
const ( LinkIssue = "issue" LinkTMS = "tms" LinkCustom = "custom" )
Link types. An unrecognised type is passed through and rejected server-side rather than silently rewritten here.
Variables ¶
This section is empty.
Functions ¶
func Attach ¶
Attach records in-memory bytes against the current test.
The payload travels inline, base64-encoded, inside a single log line, so it is bounded: anything that will not fit is dropped with a warning rather than truncated, because half a base64 payload is not a usable file. For large artifacts, write the file and reference it from your own storage.
func AttachText ¶
AttachText records a string. The mime type defaults to text/plain.
func Description ¶
Description attaches prose describing what the test covers.
func Enabled ¶
func Enabled() bool
Enabled reports whether anything is listening.
Metadata rides t.Log, so emitting when no reporter is consuming the stream would put encoded noise in a developer's `go test -v` output for no benefit. The gate is `go test -json`, which passes -test.v=test2json -- measured on Go 1.21, 1.23, 1.25 and 1.26, so it holds at this module's floor. Plain `go test -v` sets "true" and is not enough.
QUALFLARE_GO=1 forces emission on (the wrapper sets it, which is also what makes it work on a toolchain whose -json does not imply test2json), and QUALFLARE_GO=0 forces it off.
func Link ¶
Link attaches an external link. linkType is one of LinkIssue, LinkTMS or LinkCustom; empty defaults to custom.
func MaskedParameter ¶
MaskedParameter records that a parameter exists without recording its value.
It deliberately takes no value at all. The wire contract treats `masked` as a display hint and the server does NOT redact, so withholding the value here is the only thing that actually keeps a secret out of the report -- and a signature that cannot accept one cannot leak one.
func Parameter ¶
Parameter records a case- or step-level parameter. A parameter emitted while a Step is open belongs to that step.
func Step ¶
Step records a named step around fn.
Closure form only, and that is a correctness decision rather than a taste one. A begin/end pair would leak an unclosed step on t.Fatal, which calls runtime.Goexit -- and Goexit DOES run deferred functions, so a defer closes the step correctly where an explicit End() would simply never be reached.
The user's panic is re-raised unchanged after the step is recorded. Nothing here alters control flow: a reporter that swallowed a panic would turn a failing test green, which is the worst thing it could possibly do.
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
qualflare-go
command
Command qualflare-go turns a `go test -json` stream into a Qualflare report.
|
Command qualflare-go turns a `go test -json` stream into a Qualflare report. |
|
internal
|
|
|
build
Package build assembles a Collect report from the run model.
|
Package build assembles a Collect report from the run model. |
|
cidetect
Package cidetect identifies the CI provider from its environment variables.
|
Package cidetect identifies the CI provider from its environment variables. |
|
config
Package config resolves the reporter's configuration.
|
Package config resolves the reporter's configuration. |
|
constants
Package constants holds the caps the Qualflare wire contract and server enforce.
|
Package constants holds the caps the Qualflare wire contract and server enforce. |
|
gitdetect
Package gitdetect reads branch and commit from git, used only when CI variables are absent.
|
Package gitdetect reads branch and commit from git, used only when CI variables are absent. |
|
model
Package model turns a `go test -json` event stream into a faithful record of what ran.
|
Package model turns a `go test -json` event stream into a faithful record of what ran. |
|
replay
Package replay turns a test's sentinel messages into the fields of one Case.
|
Package replay turns a test's sentinel messages into the fields of one Case. |
|
runner
Package runner executes `go test -json` and tees its stream.
|
Package runner executes `go test -json` and tees its stream. |
|
sentinel
Package sentinel is the wire format carrying metadata from a test process to the reporter, and the one contract both halves of this module import.
|
Package sentinel is the wire format carrying metadata from a test process to the reporter, and the one contract both halves of this module import. |
|
stream
Package stream decodes a `go test -json` event stream.
|
Package stream decodes a `go test -json` event stream. |
|
textutil
Package textutil holds text clamping helpers.
|
Package textutil holds text clamping helpers. |
|
version
Package version reports what build this is.
|
Package version reports what build this is. |
|
wire
Package wire is the Qualflare Collect contract.
|
Package wire is the Qualflare Collect contract. |