Godog

go get github.com/tracera-dev/tracera-go/godog

Requires Go ≥ 1.25 and Godog ≥ 0.16 (see Autotest adapters). godog on pkg.go.dev.

Environment variables and run mode: Autotest adapters.

Wire the suite and scenario initializer so stock After hooks map to Teardown (Godog runs After hooks in registration order):

import (
    "github.com/cucumber/godog"
    tracera_godog "github.com/tracera-dev/tracera-go/godog"
)

suite := godog.TestSuite{
    TestSuiteInitializer: tracera_godog.RegisterSuite,
    ScenarioInitializer: tracera_godog.Initialize(func(sc *godog.ScenarioContext) {
        sc.Before(setup)
        sc.After(teardown)
        // step definitions …
    }),
}

Bind testCaseId and autotestName

Prefer Scenario tags:

@tracera.id:42
Scenario: Checkout
  Given the cart is open

Optional @tracera.name: is URL-encoded. If the name tag is omitted, autotestName takes the value of the Scenario name.

Or bind imperatively with tracera.TestCase(42).

Skip

Return godog.ErrSkip from a step definition to skip the Scenario. To add a reason as the result comment, wrap it:

return fmt.Errorf("needs a seeded account: %w", godog.ErrSkip)

You can also exclude scenarios with Godog --tags.

If a step is pending (not implemented yet) or undefined (no matching step definition), Godog does not fail the Scenario in the default mode — Tracera reports the whole Scenario as Skipped. Those steps do not appear under Steps, and the result has no error.

Steps

Gherkin steps map to the result’s Test. Nest helpers with tracera.Step("…", func() { … }). Before/After scenario hooks map to Setup / Teardown; suite hooks are not reported.

func addItem() error {
    tracera.Step("nested leaf", func() {})
    return nil
}

Comments, errors, and attachments

Limits and allowed MIME types: Autotest adapters.

Use tracera.Comment, tracera.Error, tracera.AttachmentFile, and tracera.AttachmentBytes on the open Gherkin step or the result.

If you start a goroutine and call Tracera APIs there (steps, comments, errors, attachments), save the context on the test goroutine first and run the worker with tracera.RunWithContext — otherwise those calls are not reported:

ctx := tracera.GetContext()
go tracera.RunWithContext(ctx, func() {
    tracera.Step("worker", func() { /* ... */ })
})

Scenario concurrency (godog.Options.Concurrency > 1) needs no extra Tracera setup.

Parameterized

Each Examples row gets a Scenario name with <…> already filled in by Godog. Put a fixed @tracera.id: on the Outline or Scenario, or call tracera.TestCase when the id varies per example.

@tracera.id:42
Scenario Outline: Login as <login>
  Given the user signs in as "<login>"
  Examples:
    | login |
    | ok    |
    | sso   |