reduce stdout logs in tests

Keep the stdout clean if all tests are passed. It helps to debug a broken test, because only a failed test prints to output.
This commit is contained in:
Dmitry Kutakov
2019-12-29 16:58:34 +01:00
parent 25e0c70969
commit 94a1912e25
4 changed files with 115 additions and 99 deletions

View File

@@ -93,7 +93,7 @@ func TestParseAndRunShortOpts(t *testing.T) {
},
}
app := NewApp()
app := newTestApp()
app.Commands = []*Command{cmd}
err := app.Run(c.testArgs)
@@ -116,6 +116,7 @@ func TestCommand_Run_DoesNotOverwriteErrorFromBefore(t *testing.T) {
},
},
},
Writer: ioutil.Discard,
}
err := app.Run([]string{"foo", "bar"})
@@ -317,12 +318,12 @@ func TestCommandSkipFlagParsing(t *testing.T) {
&StringFlag{Name: "flag"},
},
Action: func(c *Context) error {
fmt.Printf("%+v\n", c.String("flag"))
args = c.Args()
return nil
},
},
},
Writer: ioutil.Discard,
}
err := app.Run(c.testArgs)