package util import ( "fmt" "os" "testing" "github.com/stretchr/testify/assert" ) func TestCaptureOutput(t *testing.T) { result := CaptureOutput(func() { fmt.Fprint(os.Stdout, "foo") fmt.Fprint(os.Stderr, "bar") }) assert.Equal(t, "foobar", result) }