Skip to content

Commit

Permalink
feat: add log message in the test report (#361)
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy authored Jul 30, 2024
1 parent bdacfd8 commit c647f95
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/tools/testing/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ func TestPrettyReporter(t *testing.T) {
result := TestResult{
Info: []TestCaseInfo{
{
Name: "test_foo",
Duration: 1024,
Name: "test_foo",
Duration: 1024,
LogMessage: "log message",
},
{
Name: "test_bar",
Expand All @@ -30,6 +31,7 @@ func TestPrettyReporter(t *testing.T) {
}

exp := `test_foo: PASS (1ms)
log message
test_bar: FAIL (2ms)
Error: assert failed
--------------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions pkg/tools/testing/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ func (t *TestCaseInfo) Skip() bool {

func (t *TestCaseInfo) Format() string {
status := fmt.Sprintf("%s: %s (%dms)", t.Name, t.StatusString(), t.Duration/1000)
if t.LogMessage != "" {
return fmt.Sprintf("%s\n%s", status, t.LogMessage)
}
if t.Fail() {
return fmt.Sprintf("%s\n%s", status, t.ErrMessage)
}
Expand Down

0 comments on commit c647f95

Please sign in to comment.