Exemplo n.º 1
0
func (r *Runner) RunFeature(t matchers.Errorable, ctx interface{}, filename string) {
	file, err := os.Open(filename)
	if err != nil {
		t.Errorf(err.Error())
	}
	data, _ := ioutil.ReadAll(file)
	rpt := r.Execute(string(data), ctx)
	PrintReport(rpt, r.output)
	if rpt.failedSteps > 0 {
		t.Errorf("Failed %s", file)
	}
}
Exemplo n.º 2
0
// Once the step definitions are Register()'d, use Run() to
// locate all *.feature files within the feature/ subdirectory
// of the current directory.
func (r *Runner) Run(t matchers.Errorable) {
	featureMatch, _ := re.Compile(`.*\.feature`)
	filepath.Walk("features", func(walkPath string, info os.FileInfo, err error) error {
		if err != nil {
			return err
		}
		if info.Name() != "features" && info.IsDir() {
			return filepath.SkipDir
		} else if !info.IsDir() && featureMatch.MatchString(info.Name()) {
			file, _ := os.Open(walkPath)
			data, _ := ioutil.ReadAll(file)
			rpt := r.Execute(string(data))
			PrintReport(rpt, r.output)
			r.scenarios = []Scenario{}
			r.background = nil
			if rpt.failedSteps > 0 {
				t.Errorf("Failed %s", file)
			}
		}
		return nil
	})
}