forked from cucumber/godog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fmt_test.go
67 lines (55 loc) · 1.55 KB
/
fmt_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package godog_test
import (
"io"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/cucumber/godog"
)
func Test_FindFmt(t *testing.T) {
cases := map[string]bool{
"cucumber": true,
"custom": true, // is available for test purposes only
"events": true,
"junit": true,
"pretty": true,
"progress": true,
"unknown": false,
"undef": false,
}
for name, expected := range cases {
t.Run(
name,
func(t *testing.T) {
actual := godog.FindFmt(name)
if expected {
assert.NotNilf(t, actual, "expected %s formatter should be available", name)
} else {
assert.Nilf(t, actual, "expected %s formatter should be available", name)
}
},
)
}
}
func Test_AvailableFormatters(t *testing.T) {
expected := map[string]string{
"cucumber": "Produces cucumber JSON format output.",
"custom": "custom format description", // is available for test purposes only
"events": "Produces JSON event stream, based on spec: 0.1.0.",
"junit": "Prints junit compatible xml to stdout",
"pretty": "Prints every feature with runtime statuses.",
"progress": "Prints a character per step.",
}
actual := godog.AvailableFormatters()
assert.Equal(t, expected, actual)
}
func Test_Format(t *testing.T) {
actual := godog.FindFmt("Test_Format")
require.Nil(t, actual)
godog.Format("Test_Format", "...", testFormatterFunc)
actual = godog.FindFmt("Test_Format")
assert.NotNil(t, actual)
}
func testFormatterFunc(suiteName string, out io.Writer) godog.Formatter {
return nil
}