godog/example_subtests_test.go
2021-08-11 17:19:05 +02:00

45 строки
1 010 Б
Go

package godog_test
import (
"testing"
"github.com/cucumber/godog"
)
func ExampleTestSuite_Run_subtests() {
var t *testing.T // Comes from your test function, e.g. func TestFeatures(t *testing.T).
suite := godog.TestSuite{
ScenarioInitializer: func(s *godog.ScenarioContext) {
// Add step definitions here.
},
Options: &godog.Options{
Format: "pretty",
Paths: []string{"features"},
TestingT: t, // Testing instance that will run subtests.
},
}
if suite.Run() != 0 {
t.Fatal("non-zero status returned, failed to run feature tests")
}
}
func TestFeatures(t *testing.T) {
suite := godog.TestSuite{
ScenarioInitializer: func(s *godog.ScenarioContext) {
godog.InitializeScenario(s)
// Add step definitions here.
},
Options: &godog.Options{
Format: "pretty",
Paths: []string{"features"},
TestingT: t, // Testing instance that will run subtests.
},
}
if suite.Run() != 0 {
t.Fatal("non-zero status returned, failed to run feature tests")
}
}