From cc861097ae40fabb4f0e559429a0e9a2dd4f673e Mon Sep 17 00:00:00 2001 From: Jayson Smith Date: Wed, 4 Mar 2020 21:53:10 -0700 Subject: [PATCH] Add suite_test.go back --- go.mod | 6 +++++- go.sum | 4 ++++ suite_test.go | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 suite_test.go diff --git a/go.mod b/go.mod index 7fcdb3a..2924270 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,8 @@ module github.com/cucumber/godog go 1.13 -require github.com/stretchr/testify v1.4.0 +require ( + github.com/DATA-DOG/go-txdb v0.1.3 + github.com/go-sql-driver/mysql v1.5.0 + github.com/stretchr/testify v1.4.0 +) diff --git a/go.sum b/go.sum index 8fdee58..77d1d3f 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,9 @@ +github.com/DATA-DOG/go-txdb v0.1.3 h1:R4v6OuOcy2O147e2zHxU0B4NDtF+INb5R9q/CV7AEMg= +github.com/DATA-DOG/go-txdb v0.1.3/go.mod h1:DhAhxMXZpUJVGnT+p9IbzJoRKvlArO2pkHjnGX7o0n0= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= +github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/suite_test.go b/suite_test.go new file mode 100644 index 0000000..aabffe4 --- /dev/null +++ b/suite_test.go @@ -0,0 +1,46 @@ +package godog + +import ( + "os" + "strings" + "testing" + "time" +) + +func TestMain(m *testing.M) { + format := "progress" // non verbose mode + concurrency := 4 + + var specific bool + for _, arg := range os.Args[1:] { + if arg == "-test.v=true" { // go test transforms -v option - verbose mode + format = "pretty" + concurrency = 1 + break + } + if strings.Index(arg, "-test.run") == 0 { + specific = true + } + } + var status int + if !specific { + status = RunWithOptions("godog", func(s *Suite) { + GodogContext(s) + }, Options{ + Format: format, // pretty format for verbose mode, otherwise - progress + Paths: []string{"features"}, + Concurrency: concurrency, // concurrency for verbose mode is 1 + Randomize: time.Now().UnixNano(), // randomize scenario execution order + }) + } + + if st := m.Run(); st > status { + status = st + } + os.Exit(status) +} + +// needed in order to use godog cli +func GodogContext(s *Suite) { + SuiteContext(s) +}