Skip to content

Commit

Permalink
Add coverage for Fail, Skipf, FailedAndSkipped (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
prashantv authored Jan 14, 2025
1 parent c2c9c0c commit a503591
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
10 changes: 10 additions & 0 deletions faket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,13 @@ func TestFakeT_Success(t *testing.T) {

want.DeepEqual(t, "Logs", res.Logs().Messages(), []string{"this is log 1"})
}

func TestFakeT_FailSkip(t *testing.T) {
tr := RunTest(func(t testing.TB) {
t.Error("about to skip")
t.Skipf("skip %s", t.Name())
})
want.Equal(t, "Skipped", tr.Skipped(), false)
want.Equal(t, "Failed", tr.Failed(), true)
want.Equal(t, "FailedAndSkipped", tr.FailedAndSkipped(), true)
}
12 changes: 12 additions & 0 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,15 @@ func TestCmp_SkipNow(t *testing.T) {
t.Error("post-skip log")
})
}

func TestCmp_Fail(t *testing.T) {
cmptest.Compare(t, func(t testing.TB) {
t.Fail()
})
}

func TestCmp_Skipf(t *testing.T) {
cmptest.Compare(t, func(t testing.TB) {
t.Skipf("skip %s", "test")
})
}
9 changes: 9 additions & 0 deletions testdata/cmp_test_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@
{"Time":"2022-06-11T00:00:00.0Z","Action":"output","Package":"github.com/prashantv/faket","Test":"TestCmp_SkipNow","Output":" integration_test.go:338: pre-skip log\n"}
{"Time":"2022-06-11T00:00:00.0Z","Action":"output","Package":"github.com/prashantv/faket","Test":"TestCmp_SkipNow","Output":"--- FAIL: TestCmp_SkipNow (0.01s)\n"}
{"Time":"2022-06-11T00:00:00.0Z","Action":"fail","Package":"github.com/prashantv/faket","Test":"TestCmp_SkipNow","Elapsed":0}
{"Time":"2022-06-11T00:00:00.0Z","Action":"run","Package":"github.com/prashantv/faket","Test":"TestCmp_Fail"}
{"Time":"2022-06-11T00:00:00.0Z","Action":"output","Package":"github.com/prashantv/faket","Test":"TestCmp_Fail","Output":"=== RUN TestCmp_Fail\n"}
{"Time":"2022-06-11T00:00:00.0Z","Action":"output","Package":"github.com/prashantv/faket","Test":"TestCmp_Fail","Output":"--- FAIL: TestCmp_Fail (0.01s)\n"}
{"Time":"2022-06-11T00:00:00.0Z","Action":"fail","Package":"github.com/prashantv/faket","Test":"TestCmp_Fail","Elapsed":0}
{"Time":"2022-06-11T00:00:00.0Z","Action":"run","Package":"github.com/prashantv/faket","Test":"TestCmp_Skipf"}
{"Time":"2022-06-11T00:00:00.0Z","Action":"output","Package":"github.com/prashantv/faket","Test":"TestCmp_Skipf","Output":"=== RUN TestCmp_Skipf\n"}
{"Time":"2022-06-11T00:00:00.0Z","Action":"output","Package":"github.com/prashantv/faket","Test":"TestCmp_Skipf","Output":" integration_test.go:352: skip test\n"}
{"Time":"2022-06-11T00:00:00.0Z","Action":"output","Package":"github.com/prashantv/faket","Test":"TestCmp_Skipf","Output":"--- SKIP: TestCmp_Skipf (0.01s)\n"}
{"Time":"2022-06-11T00:00:00.0Z","Action":"skip","Package":"github.com/prashantv/faket","Test":"TestCmp_Skipf","Elapsed":0}
{"Time":"2022-06-11T00:00:00.0Z","Action":"output","Package":"github.com/prashantv/faket","Output":"FAIL\n"}
{"Time":"2022-06-11T00:00:00.0Z","Action":"output","Package":"github.com/prashantv/faket","Output":"exit status 1\n"}
{"Time":"2022-06-11T00:00:00.0Z","Action":"output","Package":"github.com/prashantv/faket","Output":"FAIL\tgithub.com/prashantv/faket\t0.01s\n"}
Expand Down

0 comments on commit a503591

Please sign in to comment.