gotest

go get github.com/tracera-dev/tracera-go/gotest/v2

Tested on Go 1.25–1.27 (see Autotest adapters). gotest on pkg.go.dev.

Environment variables and run mode: Autotest adapters.

Wire reporting once from TestMain:

package checkout_test

import (
    "os"
    "testing"

    "github.com/tracera-dev/tracera-go/gotest/v2"
)

func TestMain(m *testing.M) {
    os.Exit(gotest.Run(m))
}

Bind testCaseId and autotestName

Use stock testing and imperative bind:

func TestCheckout(t *testing.T) {
    gotest.TestCase(t, 42)
    // gotest.TestCase(t, 42, "e2e/checkout")
}

In parallel tests, call t.Parallel() before gotest.TestCase.

Skip

Use gotest.Skip / gotest.Skipf so the reason is added to the result as comment (stock t.Skip alone does not):

func TestCheckout(t *testing.T) {
    gotest.TestCase(t, 42)
    gotest.Skip(t, "needs a seeded account")
}

Steps

Use tracera.Step("…", func() { … }). Go has no method-step decorator. Steps inside tracera.Setup / tracera.Teardown go to Setup / Teardown; other steps go to Test.

A panic inside tracera.Step marks that step Failed, adds the message and the stack to it, and marks the result Failed. t.Fatal, t.FailNow, and require inside the step mark that step and the result Failed. Their assertion text is not written on the step. t.Error marks the result Failed. The assertion text stays in the go test output. Call tracera.Error to put a message on the card.

import (
    "testing"

    tracera "github.com/tracera-dev/tracera-go/v2"
    "github.com/tracera-dev/tracera-go/gotest/v2"
)

func TestCheckout(t *testing.T) {
    gotest.TestCase(t, 10)

    tracera.Setup("open shop", func() {})
    tracera.Step("add item", func() {
        tracera.Step("nested leaf", func() {})
    })
    tracera.Teardown("close shop", func() {})
}

Comments, errors, and attachments

Limits and allowed MIME types: Autotest adapters.

tracera.Comment, tracera.Error, and attachments are added to the open step, or to the result when no step is open. tracera.AttachmentFile takes a file path; tracera.AttachmentBytes takes a name and bytes (MIME type is optional). Attachments upload when the result is reported.

import tracera "github.com/tracera-dev/tracera-go/v2"

tracera.Comment("result-level note")
tracera.Error("result-level error")
tracera.AttachmentFile("testdata/screenshot.png")
tracera.Step("open login", func() {
    tracera.Comment("step note")
    tracera.AttachmentBytes("body.json", []byte(`{"ok":true}`), "application/json")
})

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() { /* ... */ })
})

Parameterized

Use t.Run rows. Pass a name on TestCase when you want a stable label per row:

func TestMatrix(t *testing.T) {
    for _, row := range []struct{ login string }{{"alice"}, {"bob"}} {
        t.Run(row.login, func(t *testing.T) {
            gotest.TestCase(t, 7, "login as "+row.login)
        })
    }
}