github.com/Secbyte/godog@v0.7.14-0.20200116175429-d8f0aeeb70cf/suite_test.go (about) 1 package godog 2 3 import ( 4 "os" 5 "strings" 6 "testing" 7 "time" 8 ) 9 10 func TestMain(m *testing.M) { 11 format := "progress" // non verbose mode 12 concurrency := 4 13 14 var specific bool 15 for _, arg := range os.Args[1:] { 16 if arg == "-test.v=true" { // go test transforms -v option - verbose mode 17 format = "pretty" 18 concurrency = 1 19 break 20 } 21 if strings.Index(arg, "-test.run") == 0 { 22 specific = true 23 } 24 } 25 var status int 26 if !specific { 27 status = RunWithOptions("godog", func(s *Suite) { 28 GodogContext(s) 29 }, Options{ 30 Format: format, // pretty format for verbose mode, otherwise - progress 31 Paths: []string{"features"}, 32 Concurrency: concurrency, // concurrency for verbose mode is 1 33 Randomize: time.Now().UnixNano(), // randomize scenario execution order 34 }) 35 } 36 37 if st := m.Run(); st > status { 38 status = st 39 } 40 os.Exit(status) 41 } 42 43 // needed in order to use godog cli 44 func GodogContext(s *Suite) { 45 SuiteContext(s) 46 }