Add common test logging methods such as Errorf/Fatalf/Printf

Implements nearly all of the test logging methods for both T and B
structs. Majority of the code has been copied from:
golang.org/src/testing/testing.go
then updated to match the existing testing.go structure.

Code structure/function/method order mimics upstream.

Both FailNow() and SkipNow() cannot be completely implemented,
because they require an early exit from the goroutine. Instead,
they call Error() to report the limitation.

This incomplete implementation allows more detailed test logging and
increases compatiblity with upstream.
This commit is contained in:
Brad Erickson
2019-08-10 18:23:35 -07:00
committed by Ron Evans
parent fd3309afa8
commit 61f711ef26
3 changed files with 167 additions and 25 deletions
+7 -1
View File
@@ -9,10 +9,16 @@ func TestFail1(t *testing.T) {
}
func TestFail2(t *testing.T) {
t.Error("TestFail2 failed for reasons")
t.Fatalf("TestFail2 failed for %v ", "reasons")
}
func TestFail3(t *testing.T) {
t.Fail()
t.Logf("TestFail3 failed for %v ", "reasons")
}
func TestPass(t *testing.T) {
t.Log("TestPass passed")
}
func BenchmarkNotImplemented(b *testing.B) {