mercredi 19 septembre 2018

Why does the golang testing package replace spaces with underscores when reporting test failures?

When I run this test and it fails:

func TestCaseA(t *testing.T){
    t.Run("my name with spaces", func (t *testing.T){
        t.Error("some error message")
    })
}

then the name of the test is modified (spaces are changed to underscores) in the output:

--- FAIL: TestCaseA (0.00s)
    --- FAIL: TestCaseA/my_name_with_spaces (0.00s)
        main.go:10: some error message
FAIL

Why does it do this?

Here's a working example: https://play.golang.org/p/viZjC60Dazg

Aucun commentaire:

Enregistrer un commentaire