Merge branch 'master' into release/v0.9.0
Этот коммит содержится в:
коммит
0ab3e09327
8 изменённых файлов: 126 добавлений и 13 удалений
1
.gitignore
предоставленный
1
.gitignore
предоставленный
|
@ -5,3 +5,4 @@ Gopkg.lock
|
|||
Gopkg.toml
|
||||
|
||||
.DS_Store
|
||||
.idea
|
|
@ -16,7 +16,6 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt
|
|||
|
||||
- Run godog features in CircleCI in strict mode ([jaysonesmith])
|
||||
- Removed TestMain call in `suite_test.go` for CI. ([jaysonesmith])
|
||||
- Migrated to [gherkin-go - v9.2.0](https://github.com/cucumber/gherkin-go/releases/tag/v9.2.0). ([240](https://github.com/cucumber/godog/pull/240) - [lonnblad])
|
||||
|
||||
### Deprecated
|
||||
|
||||
|
@ -28,6 +27,7 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt
|
|||
- Re enable custom formatters. ([238](https://github.com/cucumber/godog/pull/238) - [ericmcbride])
|
||||
- Added back suite_test.go ([jaysonesmith])
|
||||
- Normalise module paths for use on Windows ([242](https://github.com/cucumber/godog/pull/242) - [gjtaylor])
|
||||
- Fixed panic in indenting function `s`([247](https://github.com/cucumber/godog/pull/247) - [titouanfreville])
|
||||
|
||||
## [0.8.1]
|
||||
|
||||
|
@ -78,3 +78,4 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt
|
|||
[smikulcik]: https://github.com/smikulcik
|
||||
[ericmcbride]: https://github.com/ericmcbride
|
||||
[gjtaylor]: https://github.com/gjtaylor
|
||||
[titouanfreville]: https://github.com/titouanfreville
|
||||
|
|
17
README.md
17
README.md
|
@ -36,6 +36,23 @@ executable to determine compiler and linker.
|
|||
The following about section was taken from
|
||||
[cucumber](https://cucumber.io/) homepage.
|
||||
|
||||
## Notice:
|
||||
|
||||
**If your project depend on the master version of godog instead of a specific release, please read this.**
|
||||
|
||||
Due to dependency changes in a coming merge to master, including breaking changes, you should update how you install or depend on godog so that you have a version specified.
|
||||
|
||||
### Install
|
||||
```
|
||||
go get github.com/cucumber/godog/cmd/godog@v0.8.1
|
||||
```
|
||||
Adding `@v0.8.1` will install v0.8.1 specifically instead of master.
|
||||
|
||||
Running `within the $GOPATH`, you would also need to set `GO111MODULE=on`, like this:
|
||||
```
|
||||
GO111MODULE=on go get github.com/cucumber/godog/cmd/godog@v0.8.1
|
||||
```
|
||||
|
||||
## About
|
||||
|
||||
#### A single source of truth
|
||||
|
|
|
@ -45,6 +45,7 @@ Feature: pretty formatter
|
|||
No steps
|
||||
0s
|
||||
"""
|
||||
|
||||
Scenario: Support of Feature Plus Scenario Outline
|
||||
Given a feature "features/simple.feature" file:
|
||||
"""
|
||||
|
@ -111,6 +112,7 @@ Feature: pretty formatter
|
|||
No steps
|
||||
0s
|
||||
"""
|
||||
|
||||
Scenario: Support of Feature Plus Scenario With Steps
|
||||
Given a feature "features/simple.feature" file:
|
||||
"""
|
||||
|
@ -146,6 +148,7 @@ Feature: pretty formatter
|
|||
2 steps (1 passed, 1 failed)
|
||||
0s
|
||||
"""
|
||||
|
||||
Scenario: Support of Feature Plus Scenario Outline With Steps
|
||||
Given a feature "features/simple.feature" file:
|
||||
"""
|
||||
|
@ -214,6 +217,7 @@ Feature: pretty formatter
|
|||
No steps
|
||||
0s
|
||||
"""
|
||||
|
||||
Scenario: Support of Docstrings
|
||||
Given a feature "features/simple.feature" file:
|
||||
"""
|
||||
|
@ -244,6 +248,7 @@ Feature: pretty formatter
|
|||
1 steps (1 passed)
|
||||
0s
|
||||
"""
|
||||
|
||||
Scenario: Support of Undefined, Pending and Skipped status
|
||||
Given a feature "features/simple.feature" file:
|
||||
"""
|
||||
|
@ -286,3 +291,41 @@ Feature: pretty formatter
|
|||
s.Step(`^undefined$`, undefined)
|
||||
}
|
||||
"""
|
||||
|
||||
# Ensure s will not break when injecting data from BeforeStep
|
||||
Scenario: Support data injection in BeforeStep
|
||||
Given a feature "features/inject.feature" file:
|
||||
"""
|
||||
Feature: inject long value
|
||||
|
||||
Scenario: test scenario
|
||||
Given Ignore I save some value X under key Y
|
||||
And I allow variable injection
|
||||
When Ignore I use value {{Y}}
|
||||
Then Ignore Godog rendering should not break
|
||||
And Ignore test
|
||||
| key | val |
|
||||
| 1 | 2 |
|
||||
| 3 | 4 |
|
||||
And I disable variable injection
|
||||
"""
|
||||
When I run feature suite with formatter "pretty"
|
||||
Then the rendered output will be as follows:
|
||||
"""
|
||||
Feature: inject long value
|
||||
|
||||
Scenario: test scenario # features/inject.feature:3
|
||||
Given Ignore I save some value X under key Y # suite_context.go:0 -> SuiteContext.func7
|
||||
And I allow variable injection # suite_context.go:0 -> *suiteContext
|
||||
When Ignore I use value someverylonginjectionsoweacanbesureitsurpasstheinitiallongeststeplenghtanditwillhelptestsmethodsafety # suite_context.go:0 -> SuiteContext.func7
|
||||
Then Ignore Godog rendering should not break # suite_context.go:0 -> SuiteContext.func7
|
||||
And Ignore test # suite_context.go:0 -> SuiteContext.func7
|
||||
| key | val |
|
||||
| 1 | 2 |
|
||||
| 3 | 4 |
|
||||
And I disable variable injection # suite_context.go:0 -> *suiteContext
|
||||
|
||||
1 scenarios (1 passed)
|
||||
6 steps (6 passed)
|
||||
0s
|
||||
"""
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<testsuites name="succeed" tests="78" skipped="0" failures="0" errors="0" time="0">
|
||||
<testsuites name="succeed" tests="79" skipped="0" failures="0" errors="0" time="0">
|
||||
<testsuite name="JUnit XML formatter" tests="9" skipped="0" failures="0" errors="0" time="0">
|
||||
<testcase name="Support of Feature Plus Scenario Node" status="passed" time="0"></testcase>
|
||||
<testcase name="Support of Feature Plus Scenario Node With Tags" status="passed" time="0"></testcase>
|
||||
|
@ -35,7 +35,7 @@
|
|||
<testcase name="loaded feature should have a number of scenarios #3" status="passed" time="0"></testcase>
|
||||
<testcase name="load a number of feature files" status="passed" time="0"></testcase>
|
||||
</testsuite>
|
||||
<testsuite name="pretty formatter" tests="9" skipped="0" failures="0" errors="0" time="0">
|
||||
<testsuite name="pretty formatter" tests="10" skipped="0" failures="0" errors="0" time="0">
|
||||
<testcase name="Support of Feature Plus Scenario Node" status="passed" time="0"></testcase>
|
||||
<testcase name="Support of Feature Plus Scenario Node With Tags" status="passed" time="0"></testcase>
|
||||
<testcase name="Support of Feature Plus Scenario Outline" status="passed" time="0"></testcase>
|
||||
|
@ -45,6 +45,7 @@
|
|||
<testcase name="Support of Comments" status="passed" time="0"></testcase>
|
||||
<testcase name="Support of Docstrings" status="passed" time="0"></testcase>
|
||||
<testcase name="Support of Undefined, Pending and Skipped status" status="passed" time="0"></testcase>
|
||||
<testcase name="Support data injection in BeforeStep" status="passed" time="0"></testcase>
|
||||
</testsuite>
|
||||
<testsuite name="run background" tests="3" skipped="0" failures="0" errors="0" time="0">
|
||||
<testcase name="should run background steps" status="passed" time="0"></testcase>
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
...................................................................... 140
|
||||
...................................................................... 210
|
||||
...................................................................... 280
|
||||
....................... 303
|
||||
.......................... 306
|
||||
|
||||
|
||||
78 scenarios (78 passed)
|
||||
303 steps (303 passed)
|
||||
79 scenarios (79 passed)
|
||||
306 steps (306 passed)
|
||||
0s
|
|
@ -45,6 +45,7 @@ func SuiteContext(s *Suite, additionalContextInitializers ...func(suite *Suite))
|
|||
s.Step(`^I run feature suite$`, c.iRunFeatureSuite)
|
||||
s.Step(`^I run feature suite with tags "([^"]*)"$`, c.iRunFeatureSuiteWithTags)
|
||||
s.Step(`^I run feature suite with formatter "([^"]*)"$`, c.iRunFeatureSuiteWithFormatter)
|
||||
s.Step(`^(?:I )(allow|disable) variable injection`, c.iSetVariableInjectionTo)
|
||||
s.Step(`^(?:a )?feature "([^"]*)"(?: file)?:$`, c.aFeatureFile)
|
||||
s.Step(`^the suite should have (passed|failed)$`, c.theSuiteShouldHave)
|
||||
|
||||
|
@ -99,6 +100,46 @@ func SuiteContext(s *Suite, additionalContextInitializers ...func(suite *Suite))
|
|||
s.Step(`^(?:a )?failing nested multistep$`, func() Steps {
|
||||
return Steps{"passing step", "passing multistep", "failing multistep"}
|
||||
})
|
||||
// Default recovery step
|
||||
s.Step(`Ignore.*`, func() error {
|
||||
return nil
|
||||
})
|
||||
|
||||
s.BeforeStep(c.inject)
|
||||
}
|
||||
func (s *suiteContext) inject(step *gherkin.Step) {
|
||||
if !s.allowInjection {
|
||||
return
|
||||
}
|
||||
|
||||
step.Text = injectAll(step.Text)
|
||||
args := step.Argument
|
||||
if args != nil {
|
||||
switch arg := args.(type) {
|
||||
case *gherkin.DataTable:
|
||||
for i := 0; i < len(arg.Rows); i++ {
|
||||
for n, cell := range arg.Rows[i].Cells {
|
||||
arg.Rows[i].Cells[n].Value = injectAll(cell.Value)
|
||||
}
|
||||
}
|
||||
case *gherkin.DocString:
|
||||
arg.Content = injectAll(arg.Content)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func injectAll(inTo string) string {
|
||||
re := regexp.MustCompile(`{{[^{}]+}}`)
|
||||
return re.ReplaceAllStringFunc(
|
||||
inTo,
|
||||
func(key string) string {
|
||||
injectRegex := regexp.MustCompile(`^{{.+}}$`)
|
||||
if injectRegex.MatchString(key) {
|
||||
return "someverylonginjectionsoweacanbesureitsurpasstheinitiallongeststeplenghtanditwillhelptestsmethodsafety"
|
||||
}
|
||||
return key
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
type firedEvent struct {
|
||||
|
@ -107,11 +148,12 @@ type firedEvent struct {
|
|||
}
|
||||
|
||||
type suiteContext struct {
|
||||
paths []string
|
||||
testedSuite *Suite
|
||||
extraCIs []func(suite *Suite)
|
||||
events []*firedEvent
|
||||
out bytes.Buffer
|
||||
paths []string
|
||||
testedSuite *Suite
|
||||
extraCIs []func(suite *Suite)
|
||||
events []*firedEvent
|
||||
out bytes.Buffer
|
||||
allowInjection bool
|
||||
}
|
||||
|
||||
func (s *suiteContext) ResetBeforeEachScenario(*messages.Pickle) {
|
||||
|
@ -123,6 +165,12 @@ func (s *suiteContext) ResetBeforeEachScenario(*messages.Pickle) {
|
|||
SuiteContext(s.testedSuite, s.extraCIs...)
|
||||
// reset all fired events
|
||||
s.events = []*firedEvent{}
|
||||
s.allowInjection = false
|
||||
}
|
||||
|
||||
func (s *suiteContext) iSetVariableInjectionTo(to string) error {
|
||||
s.allowInjection = to == "allow"
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *suiteContext) iRunFeatureSuiteWithTags(tags string) error {
|
||||
|
@ -143,7 +191,6 @@ func (s *suiteContext) iRunFeatureSuiteWithFormatter(name string) error {
|
|||
if f == nil {
|
||||
return fmt.Errorf(`formatter "%s" is not available`, name)
|
||||
}
|
||||
|
||||
s.testedSuite.fmt = f("godog", colors.Uncolored(&s.out))
|
||||
if err := s.parseFeatures(); err != nil {
|
||||
return err
|
||||
|
|
3
utils.go
3
utils.go
|
@ -20,6 +20,9 @@ var (
|
|||
|
||||
// repeats a space n times
|
||||
func s(n int) string {
|
||||
if n < 0 {
|
||||
n = 1
|
||||
}
|
||||
return strings.Repeat(" ", n)
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче