runs tests with randomized scenario order, adds verbose mode

Этот коммит содержится в:
gedi 2017-04-27 17:19:27 +03:00
родитель 90b8d3bfe7
коммит 83675453b7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 56604CDCCC201556
4 изменённых файлов: 23 добавлений и 6 удалений

Просмотреть файл

@ -3,7 +3,7 @@ go:
- 1.5
- 1.6
- 1.7
- tip
- 1.8
go_import_path: github.com/DATA-DOG/godog

Просмотреть файл

@ -1,4 +1,4 @@
.PHONY: test gherkin bump
.PHONY: test gherkin bump cover
VERS := $(shell grep 'const Version' -m 1 godog.go | awk -F\" '{print $$2}')
@ -25,3 +25,8 @@ bump:
@sed -i.bak 's/$(VERS)/$(VERSION)/g' godog.go
@sed -i.bak 's/$(VERS)/$(VERSION)/g' examples/api/version.feature
@find . -name '*.bak' | xargs rm
cover:
go test -race -coverprofile=coverage.txt
go tool cover -html=coverage.txt
rm coverage.txt

Просмотреть файл

@ -35,7 +35,7 @@ var descRandomOption = "Randomly shuffle the scenario execution order.\n" +
// FlagSet allows to manage flags by external suite runner
func FlagSet(opt *Options) *flag.FlagSet {
descFormatOption := "How to format tests output. Available formats:\n"
descFormatOption := "How to format tests output. Built-in formats:\n"
// @TODO: sort by name
for name, desc := range AvailableFormatters() {
descFormatOption += s(4) + "- " + colors.Yellow(name) + ": " + desc + "\n"

Просмотреть файл

@ -11,17 +11,29 @@ import (
"strconv"
"strings"
"testing"
"time"
"github.com/DATA-DOG/godog/gherkin"
)
func TestMain(m *testing.M) {
status := RunWithOptions("godogs", func(s *Suite) {
format := "progress" // non verbose mode
concurrency := 4
for _, arg := range os.Args[1:] {
if arg == "-test.v=true" { // go test transforms -v option - verbose mode
format = "pretty"
concurrency = 1
break
}
}
status := RunWithOptions("godog", func(s *Suite) {
SuiteContext(s)
}, Options{
Format: "progress",
Format: format, // pretty format for verbose mode, otherwise - progress
Paths: []string{"features"},
Concurrency: 4,
Concurrency: concurrency, // concurrency for verbose mode is 1
Randomize: time.Now().UnixNano(), // randomize scenario execution order
})
if st := m.Run(); st > status {