-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (41 loc) · 1014 Bytes
/
main.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
package main
import (
"os"
"strconv"
"strings"
"github.com/playlyfe/cucumber/core"
"github.com/playlyfe/cucumber/formatter"
)
func main() {
featureFilesPath := "features"
if len(os.Args) > 1 {
featureFilesPath = strings.TrimSuffix(os.Args[1], "/")
}
cucumber := NewCucumber()
cucumber.AddOuputFormatter(formatter.NewPrettyFormatter())
cucumber.Execute(&core.ExecuteParams{
FeaturesPath: featureFilesPath,
})
}
func NewCucumber() *core.Cucumber {
c := core.NewCucumber()
c.AddTransform("int", &core.Transform{
CaptureRegexp: "-?\\d+",
Transformer: func(value string) (interface{}, error) {
return strconv.ParseInt(value, 10, 64)
},
})
c.AddTransform("float", &core.Transform{
CaptureRegexp: "-?\\d*\\.?\\d+",
Transformer: func(value string) (interface{}, error) {
return strconv.ParseFloat(value, 64)
},
})
c.AddTransform("string", &core.Transform{
CaptureRegexp: ".+",
Transformer: func(value string) (interface{}, error) {
return value, nil
},
})
return c
}