parse features for suite, add doc for public methods
Этот коммит содержится в:
родитель
5fdfd4f4b1
коммит
0c1d529e06
3 изменённых файлов: 29 добавлений и 9 удалений
|
@ -15,6 +15,6 @@ const (
|
|||
white
|
||||
)
|
||||
|
||||
func cl(s string, c color) string {
|
||||
return fmt.Sprintf("\033[%dm%s\033[0m", c, s)
|
||||
func cl(s interface{}, c color) string {
|
||||
return fmt.Sprintf("\033[%dm%v\033[0m", c, s)
|
||||
}
|
||||
|
|
|
@ -52,3 +52,10 @@ func (c config) features() (lst []*gherkin.Feature, err error) {
|
|||
return err
|
||||
})
|
||||
}
|
||||
|
||||
func fatal(err error) {
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
|
27
suite.go
27
suite.go
|
@ -2,19 +2,30 @@ package godog
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"log"
|
||||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"github.com/DATA-DOG/godog/gherkin"
|
||||
)
|
||||
|
||||
// Suite is an interface which allows various contexts
|
||||
// to register step definitions and event handlers
|
||||
type Suite interface {
|
||||
Step(exp *regexp.Regexp, h StepHandler)
|
||||
}
|
||||
|
||||
type suite struct {
|
||||
steps map[*regexp.Regexp]StepHandler
|
||||
steps map[*regexp.Regexp]StepHandler
|
||||
features []*gherkin.Feature
|
||||
}
|
||||
|
||||
// New initializes a suite which supports the Suite
|
||||
// interface. The instance is passed around to all
|
||||
// context initialization functions from *_test.go files
|
||||
func New() *suite {
|
||||
if !flag.Parsed() {
|
||||
flag.Parse()
|
||||
}
|
||||
return &suite{
|
||||
steps: make(map[*regexp.Regexp]StepHandler),
|
||||
}
|
||||
|
@ -24,10 +35,12 @@ func (s *suite) Step(exp *regexp.Regexp, h StepHandler) {
|
|||
s.steps[exp] = h
|
||||
}
|
||||
|
||||
// Run - runs a godog feature suite
|
||||
func (s *suite) Run() {
|
||||
if !flag.Parsed() {
|
||||
flag.Parse()
|
||||
}
|
||||
log.Println("running godoc, num registered steps:", len(s.steps), "color test:", cl("red", red))
|
||||
log.Println("will read features in path:", cl(cfg.featuresPath, yellow))
|
||||
var err error
|
||||
s.features, err = cfg.features()
|
||||
fatal(err)
|
||||
|
||||
fmt.Println("running", cl("godog", cyan)+", num registered steps:", cl(len(s.steps), yellow))
|
||||
fmt.Println("have loaded", cl(len(s.features), yellow), "features from path:", cl(cfg.featuresPath, green))
|
||||
}
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче