Skip to content

testing: Suggest add TB.Print for raw message #8783

@chai2010

Description

@chai2010
Like this:

func TestBar(t *testing.T) {
    assert(t, false, "Bar")
}

func TestFoo(t *testing.T) {
    assert(t, false, "Foo")
}

func assert(t *testing.T, condition bool, message string) {
    if !condition {
        file, line := callerFileLine()
        t.Fatalf("%s:%d: %s", file, line, message)
    }
}

func callerFileLine() (file string, line int) {
    ...
}

We need print the `assert` file/line, not the `t.Fatalf` file/line.

http://play.golang.org/p/VPpB0NA8on

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions