Skip to content

testing: Document interaction of Skip and Error #16502

Description

@bcmills
go version go1.7rc3 linux/amd64
package todo_test

import "testing"

func TestIssueFixed(t *testing.T) {
    defer func() {
        if t.Failed() {
            t.Skip("Test failed as expected; see issue XXXXXXXX.")
        }
        t.Fatal("Test did not fail as expected; please update issue XXXXXXXX.")
    }()

    t.Log("<no symptoms of issue XXXXXXXX>")
}

func TestIssueOpen(t *testing.T) {
    defer func() {
        if t.Failed() {
            t.Skip("Test failed as expected; see issue XXXXXXXX.")
        }
        t.Fatal("Test did not fail as expected; please update issue XXXXXXXX.")
    }()

    t.Error("<symptom of issue XXXXXXXX>")
}

Expected:

$ go test -v todo
=== RUN   TestIssueFixed
--- FAIL: TestIssueFixed (0.00s)
        todo_test.go:13: <no symptoms of issue XXXXXXXX>
        todo_test.go:10: Test did not fail as expected; please update issue XXXXXXXX.
=== RUN   TestIssueOpen
--- SKIP: TestIssueOpen (0.00s)
        todo_test.go:24: <symptom of issue XXXXXXXX>
        todo_test.go:19: Test failed as expected; see issue XXXXXXXX.
FAIL
exit status 1
FAIL    todo    0.018s

Actual:

$ go test -v todo
=== RUN   TestIssueFixed
--- FAIL: TestIssueFixed (0.00s)
        todo_test.go:13: <no symptoms of issue XXXXXXXX>
        todo_test.go:10: Test did not fail as expected; please update issue XXXXXXXX.
=== RUN   TestIssueOpen
--- FAIL: TestIssueOpen (0.00s)
        todo_test.go:24: <symptom of issue XXXXXXXX>
        todo_test.go:19: Test failed as expected; see issue XXXXXXXX.
FAIL
exit status 1
FAIL    todo    0.031s

I'm guessing this is not actually a bug, but I don't see anything in https://golang.org/pkg/testing/ describing how Skip and Error are supposed to interact. It doesn't seem unreasonable to think that a test could be Skipped after it has already Failed, but that turns out not to be the case as implemented.

Could someone with more in-depth knowledge of the testing package please confirm whether this behavior is intended (and, if so, update the documentation)?

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions