cucumber / godog Goto Github PK
View Code? Open in Web Editor NEWCucumber for golang
License: MIT License
Cucumber for golang
License: MIT License
After updating to latest godog all multiline string text started failing
eg. Feature
When I publish a message:
"""
{
"data": {
"point1": 1,
"point2": 2,
"point3": 3
}
}
"""
Step Definition
func iPublishAMessage(input *gherkin.DocString) error {
log.Println("Gherking", input, input.Content)
//... Do publish
return nil
}
The following error appears
reflect: Call using *gherkin.DocString as type *gherkin.DocString
Is there something wrong here?
As a user I would like to see what options I can pass to a binary so that I don't need to remember them all.
Usually this is accomplished by accepting -h or --help as parameters.
should be solved by #6
In a project using vendoring, I cannot use the vendored copy of godog.
Steps to reproduce:
*.feature
files and step_test.go
govendor add '+all,^vendor,^local,^std'
using https://github.com/kardianos/govendor (including "github.com/DATA-DOG/godog")rm -rf $GOPATHsrc/github.com/DATA-DOG/godog
godog ./features/*.features
leads to# _/tmp/godog-1465317047292377579
godog_runner_test.go:4:2: cannot find package "github.com/DATA-DOG/godog" in any of:
/usr/local/go/src/github.com/DATA-DOG/godog (from $GOROOT)
GOPATH/src/github.com/DATA-DOG/godog (from $GOPATH)
FAIL _/tmp/godog-1465317047292377579 [setup failed]
It also doesn't work, when I go to the "features" directory and run godog *.features
as well.
if those could have relations to parent nodes and had custom methods based on our domain logic then it could be possible to simplify node presentation in formatters.
Hi,
This looks very good, thanks for open sourcing it!
In a project using GB, I cannot get Godog to find my _test.go
files. Am I doing something wrong, or does it not work yet with GB-projects? Do you know of any workarounds? I think this should give enough info:
vagrant@fishbrain-bonito:~/bonito$ ls features/ src/github.com/fishbrain/bonito/cmd/bonito/
features/:
customerio.feature
src/github.com/fishbrain/bonito/cmd/bonito/:
main.go main_test.go
vagrant@fishbrain-bonito:~/bonito$ cat src/github.com/fishbrain/bonito/cmd/bonito/main_test.go
package main
import "github.com/DATA-DOG/godog"
func thereAreGodogs(arg1 int) error {
return godog.ErrPending
}
func iEat(arg1 int) error {
return godog.ErrPending
}
func thereShouldBeRemaining(arg1 int) error {
return godog.ErrPending
}
func featureContext(s *godog.Suite) {
s.Step(`^there are (\d+) godogs$`, thereAreGodogs)
s.Step(`^I eat (\d+)$`, iEat)
s.Step(`^there should be (\d+) remaining$`, thereShouldBeRemaining)
}
vagrant@fishbrain-bonito:~/bonito$ GOPATH=`pwd`/:`pwd`/vendor/:${GOPATH} godog
Feature: eat godogs
In order to be happy
As a hungry gopher
I need to be able to eat godogs
Scenario: Eat 5 out of 12 # features/customerio.feature:6
Given there are 12 godogs
When I eat 5
Then there should be 7 remaining
1 scenarios (1 undefined)
3 steps (3 undefined)
7.058498ms
You can implement step definitions for undefined steps with these snippets:
func thereAreGodogs(arg1 int) error {
return godog.ErrPending
}
func iEat(arg1 int) error {
return godog.ErrPending
}
func thereShouldBeRemaining(arg1 int) error {
return godog.ErrPending
}
func featureContext(s *godog.Suite) {
s.Step(`^there are (\d+) godogs$`, thereAreGodogs)
s.Step(`^I eat (\d+)$`, iEat)
s.Step(`^there should be (\d+) remaining$`, thereShouldBeRemaining)
}
vagrant@fishbrain-bonito:~/bonito$ GOPATH=`pwd`/:`pwd`/vendor/:${GOPATH} godog -d
there were no contexts registered, could not find any step definition..
I would be open to submitting a PR if you can give any pointers.
Given this feature file
Feature: Prove that there is an error with the pretty formatter
Blabla
Blabla
Blabla
Background:
Given the following customers exist
| ID | flag | number |
| 1 | true | 0 |
| 2 | true | 1 |
Scenario Outline: Add two numbers
Given I have number <a>
And I have another number <b>
When I add them together
Then I should receive <c>
Examples:
| a | b | c |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
When I run godog with pretty format it panics. Other formats like progress generates the missing code needed to implement this feature file.
godog -f pretty scenario_outline_and_background_error.feature
Feature: Prove that there is an error with the pretty formatter
Blabla
Blabla
Blabla
Background:
Given the following customers exist
| ID | flag | number |
| 1 | true | 0 |
| 2 | true | 1 |
Scenario Outline: Add two numbers # scenario_outline_and_background_error.feature:13
Given I have number <a>
And I have another number <b>
When I add them together
Then I should receive <c>
Examples:
| a | b | c |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
panic: runtime error: index out of range
goroutine 17 [running]:
panic(0x1ed520, 0xc4200100a0)
/usr/local/opt/go/libexec/src/runtime/panic.go:500 +0x1a1
github.com/DATA-DOG/godog.(*pretty).printOutlineExample(0xc42011c000, 0xc420132000)
/Users/andras.laczi/golang/src/github.com/DATA-DOG/godog/fmt_pretty.go:186 +0x1093
github.com/DATA-DOG/godog.(*pretty).printStepKind(0xc42011c000, 0xc4200ff700)
/Users/andras.laczi/golang/src/github.com/DATA-DOG/godog/fmt_pretty.go:286 +0x768
github.com/DATA-DOG/godog.(*pretty).Undefined(0xc42011c000, 0xc4200f4c80)
/Users/andras.laczi/golang/src/github.com/DATA-DOG/godog/fmt_pretty.go:326 +0x15b
github.com/DATA-DOG/godog.(*Suite).runStep(0xc42011e0e0, 0xc4200f4c80, 0x303520, 0xc4200fa0f0, 0x0, 0x0)
/Users/andras.laczi/golang/src/github.com/DATA-DOG/godog/suite.go:201 +0x344
github.com/DATA-DOG/godog.(*Suite).runSteps(0xc42011e0e0, 0xc420136960, 0x4, 0x4, 0x303520, 0xc4200fa0f0, 0x303520, 0xc4200fa0f0)
/Users/andras.laczi/golang/src/github.com/DATA-DOG/godog/suite.go:245 +0x7d
github.com/DATA-DOG/godog.(*Suite).runOutline(0xc42011e0e0, 0xc420132000, 0xc4201101e0, 0x2d, 0x8)
/Users/andras.laczi/golang/src/github.com/DATA-DOG/godog/suite.go:309 +0x747
github.com/DATA-DOG/godog.(*Suite).runFeature(0xc42011e0e0, 0xc4200f9e60)
/Users/andras.laczi/golang/src/github.com/DATA-DOG/godog/suite.go:335 +0x260
github.com/DATA-DOG/godog.(*Suite).run(0xc42011e0e0)
/Users/andras.laczi/golang/src/github.com/DATA-DOG/godog/suite.go:169 +0xa9
github.com/DATA-DOG/godog.(*runner).run.func1(0xc4200f43c0, 0xc4200fb09e, 0xc4200f9e60)
/Users/andras.laczi/golang/src/github.com/DATA-DOG/godog/run.go:30 +0x12e
created by github.com/DATA-DOG/godog.(*runner).run
/Users/andras.laczi/golang/src/github.com/DATA-DOG/godog/run.go:36 +0xa7
exit status 2
If you remove the background section the pretty formatter works as expected.
Using go 1.7
go version go1.7 darwin/amd64
I previously used v0.2.0 and everything was fine, however with the update to the latest version I experience an out of memory error when doing the following steps. Am I missing anything very obvious?
$ echo $GOPATH
/home/chris/Workspace/my-new-project
$ go version
go version go1.6.3 linux/amd64
$ go get github.com/DATA-DOG/godog/cmd/godog
$ ./bin/godog --version
Godog version is: v0.5.3
$ tree -L 4
.
├── bin
│ └── godog
├── features
│ └── godogs.feature
├── pkg
│ └── linux_amd64
│ └── github.com
│ └── DATA-DOG
└── src
└── github.com
└── DATA-DOG
└── godog
10 directories, 2 files
$ cat features/godogs.feature
Feature: eat godogs
In order to be happy
As a hungry gopher
I need to be able to eat godogs
Scenario: Eat 5 out of 12
Given there are 12 godogs
When I eat 5
Then there should be 7 remaining
$ ./bin/godog
fatal error: runtime: out of memory
runtime stack:
runtime.throw(0x6e5240, 0x16)
/usr/lib/golang/src/runtime/panic.go:547 +0x90
runtime.sysMap(0xcc90470000, 0xe0730000, 0x0, 0x813818)
/usr/lib/golang/src/runtime/mem_linux.go:206 +0x9b
runtime.(*mheap).sysAlloc(0x7fac80, 0xe0730000, 0x1159bb570)
/usr/lib/golang/src/runtime/malloc.go:429 +0x191
runtime.(*mheap).grow(0x7fac80, 0x70398, 0x0)
/usr/lib/golang/src/runtime/mheap.go:651 +0x63
runtime.(*mheap).allocSpanLocked(0x7fac80, 0x70394, 0xc809b37900)
/usr/lib/golang/src/runtime/mheap.go:553 +0x4f6
runtime.(*mheap).alloc_m(0x7fac80, 0x70394, 0x100000000, 0x7fc110)
/usr/lib/golang/src/runtime/mheap.go:437 +0x119
runtime.(*mheap).alloc.func1()
/usr/lib/golang/src/runtime/mheap.go:502 +0x41
runtime.systemstack(0x7ffef176b4d0)
/usr/lib/golang/src/runtime/asm_amd64.s:307 +0xab
runtime.(*mheap).alloc(0x7fac80, 0x70394, 0x10100000000, 0x414e4c)
/usr/lib/golang/src/runtime/mheap.go:503 +0x63
runtime.largeAlloc(0xe0728000, 0x7f3900000000, 0xca00000004)
/usr/lib/golang/src/runtime/malloc.go:766 +0xb3
runtime.mallocgc.func3()
/usr/lib/golang/src/runtime/malloc.go:664 +0x33
runtime.systemstack(0x7f7e00)
/usr/lib/golang/src/runtime/asm_amd64.s:291 +0x79
runtime.mstart()
/usr/lib/golang/src/runtime/proc.go:1051
goroutine 1 [running]:
runtime.systemstack_switch()
/usr/lib/golang/src/runtime/asm_amd64.s:245 fp=0xc82003f380 sp=0xc82003f378
runtime.mallocgc(0xe0728000, 0x5fe580, 0x0, 0xcae990d710)
/usr/lib/golang/src/runtime/malloc.go:665 +0x9eb fp=0xc82003f458 sp=0xc82003f380
runtime.newarray(0x5fe580, 0xe072800, 0x3)
/usr/lib/golang/src/runtime/malloc.go:798 +0xc9 fp=0xc82003f498 sp=0xc82003f458
runtime.growslice(0x5f4620, 0xcbdcaea000, 0xb38ec00, 0xb38ec00, 0xb38ec01, 0x0, 0x0, 0x0)
/usr/lib/golang/src/runtime/slice.go:100 +0x2c1 fp=0xc82003f508 sp=0xc82003f498
github.com/DATA-DOG/godog.maybeVendorPaths(0xc8200dd4a0, 0x24, 0x0, 0x0, 0x0)
/home/chris/Workspace/my-new-project/src/github.com/DATA-DOG/godog/builder.go:277 +0x597 fp=0xc82003f6a0 sp=0xc82003f508
github.com/DATA-DOG/godog.Build(0x0, 0x0, 0x0, 0x0)
/home/chris/Workspace/my-new-project/src/github.com/DATA-DOG/godog/builder.go:133 +0x13ab fp=0xc82003fc70 sp=0xc82003f6a0
main.buildAndRun(0x0, 0x0, 0x0)
/home/chris/Workspace/my-new-project/src/github.com/DATA-DOG/godog/cmd/godog/main.go:24 +0x4b fp=0xc82003fd28 sp=0xc82003fc70
main.main()
/home/chris/Workspace/my-new-project/src/github.com/DATA-DOG/godog/cmd/godog/main.go:85 +0x66c fp=0xc82003ff50 sp=0xc82003fd28
runtime.main()
/usr/lib/golang/src/runtime/proc.go:188 +0x2b0 fp=0xc82003ffa0 sp=0xc82003ff50
runtime.goexit()
/usr/lib/golang/src/runtime/asm_amd64.s:1998 +0x1 fp=0xc82003ffa8 sp=0xc82003ffa0
these could be built into the project directly, without requiring a separate go get because managing dependency versions sometimes just breaks compatibility and avoiding that would be best option. Since this library does not and will not have many dependencies - only gerkin parser.
Since after go 1.5 release compilation speed got worse, it made sense to prevent godog from compiling the test package on commands like godog --help
or godog --version
. But this will not show registered custom formatters, maybe it is worth to revisit it when go 1.8 is released
Steps to reproduce:
Expected result:
Actual result:
@l3pp4rd Good morning, hope you're fine?
I'm going to write my second go app. I would like to see, if I can setup a similar aruba
-thing in go we have with ruby.
You use the term examples
for your feature directory in your README.md which I find confusing.
Does it makes sense to change that to features
instead? Event in godog -h
you use the term features
.
godog -h
# => godog [options] [<paths>]
# =>
# => Arguments:
# => paths: Optional path(s) to execute. Can be:
# => - dir (features/)
# => - feature (*.feature)
# => - scenario at specific line (*.feature:10)
# => If no paths are listed, suite tries features path by default.
# =>
Having the same terms over all cucumbers make it easier for users to recognize things.
Example:
$ godog .
# command-line-arguments
/tmp/1461229988472036489godog.go:70: no new variables on left side of :=
$
Would be nicer with:
my_test.go:50: no new variables on left side of :=
Perhaps check how go test
does it.
When using scenario outlines with example tables the color for passed steps appears in skipped color.
See example below.
exit status 1
godog
exits with status code 0godog
should exit with status code 1vagrant@fishbrain-bonito:~/go/src/github.com/fishbrain/bonito$ make integration
export GOPATH=`pwd`/:`pwd`/vendor/:/home/vagrant/go && godog
Feature: Customer.io Notifications
Scenario: Success # ../customerio.feature:6
[...]
returned body was not expected. Actual: {"data":{"avatar":"https://cdn-staging.fishbrain.com/avatar/42/big","firstname":"John","follow_url":"https://deeplink.me/staging.fishbrain.com/profile/Johan","lastname":"Smith","name":"Angler follow you","type":"new_follower","username":"Johan"},"name":"new_follower"}
--- Failed scenarios:
../customerio.feature:10
1 scenarios (1 failed)
4 steps (3 passed, 1 failed)
624.71419ms
exit status 1
vagrant@fishbrain-bonito:~/go/src/github.com/fishbrain/bonito$ echo $?
0
When running a pretty format, it should give a template for steps which are undefined.
Hi,
The formatter pretty panics when having the following step:
s.Step(
^there are( not)? (\d+) godogs$, thereAreGodogs)
Stack trace of the panic is:
panic: runtime error: slice bounds out of range
goroutine 1 [running]:
panic(0x208d80, 0xc420010130)
/usr/local/Cellar/go/1.7.4_2/libexec/src/runtime/panic.go:500 +0x1a1
github.com/DATA-DOG/godog.(*pretty).printStep(0xc4201248c0, 0xc4201063c0, 0xc420106500, 0x2629b8)
/Users/Dogild/apomux/workspace/code/go/src/github.com/DATA-DOG/godog/fmt_pretty.go:224 +0x358
github.com/DATA-DOG/godog.(*pretty).printStepKind(0xc4201248c0, 0xc42010d1c0)
/Users/Dogild/apomux/workspace/code/go/src/github.com/DATA-DOG/godog/fmt_pretty.go:309 +0x340
github.com/DATA-DOG/godog.(*pretty).Failed(0xc4201248c0, 0xc4201063c0, 0xc420106500, 0x332660, 0xc4201057c0)
/Users/Dogild/apomux/workspace/code/go/src/github.com/DATA-DOG/godog/fmt_pretty.go:347 +0x169
github.com/DATA-DOG/godog.(*Suite).runStep.func1(0xc4200adb88, 0xc4201181c0, 0xc4201063c0, 0xc420106500)
/Users/Dogild/apomux/workspace/code/go/src/github.com/DATA-DOG/godog/suite.go:234 +0xbd
github.com/DATA-DOG/godog.(*Suite).runStep(0xc4201181c0, 0xc4201063c0, 0x0, 0x0, 0x332660, 0xc4201057c0)
/Users/Dogild/apomux/workspace/code/go/src/github.com/DATA-DOG/godog/suite.go:244 +0x17a
github.com/DATA-DOG/godog.(*Suite).runSteps(0xc4201181c0, 0xc420108d80, 0x3, 0x4, 0x0, 0x0, 0xc4201030e0, 0x21)
/Users/Dogild/apomux/workspace/code/go/src/github.com/DATA-DOG/godog/suite.go:250 +0x7d
github.com/DATA-DOG/godog.(*Suite).runScenario(0xc4201181c0, 0xc420120580, 0x0, 0x17, 0xc42011a480)
/Users/Dogild/apomux/workspace/code/go/src/github.com/DATA-DOG/godog/suite.go:367 +0x117
github.com/DATA-DOG/godog.(*Suite).runFeature(0xc4201181c0, 0xc420102de0)
/Users/Dogild/apomux/workspace/code/go/src/github.com/DATA-DOG/godog/suite.go:342 +0x2f3
github.com/DATA-DOG/godog.(*Suite).run(0xc4201181c0)
/Users/Dogild/apomux/workspace/code/go/src/github.com/DATA-DOG/godog/suite.go:173 +0xa9
github.com/DATA-DOG/godog.(*runner).run(0xc42010ce00, 0x4)
/Users/Dogild/apomux/workspace/code/go/src/github.com/DATA-DOG/godog/run.go:61 +0xcb
github.com/DATA-DOG/godog.RunWithOptions(0x23c9a4, 0x4, 0x262a48, 0x0, 0x0, 0x0, 0x23d5f3, 0x6, 0x1, 0xc42000a2d0, ...)
/Users/Dogild/apomux/workspace/code/go/src/github.com/DATA-DOG/godog/run.go:120 +0x3bc
github.com/DATA-DOG/godog.Run(0x23c9a4, 0x4, 0x262a48, 0xc4200001a0)
/Users/Dogild/apomux/workspace/code/go/src/github.com/DATA-DOG/godog/run.go:149 +0x1c7
main.main()
/var/folders/m4/xc317mcn10z87p6h40wrj0m80000gn/T/go-build207215723/github.com/DATA-DOG/godog/examples/godogs/_test/_testmain.go:14 +0x42
It looks like the method FindStringSubmatchIndex
returns an array with some -1 values, which causes the slice of bounds.
To reproduce, modify the example in examples/godogs, with
func FeatureContext(s *godog.Suite) {
s.Step(`^there are( not)? (\d+) godogs$`, thereAreGodogs)
And
func iEat(grammar string, num int) error {
if Godogs < num {
2 days ago gherkin-go
updated some types declared at ast.go
ScenarioOutline.Examples is now an []interface{}
https://github.com/cucumber/gherkin-go/blob/master/ast.go#L46-L50
type ScenarioOutline struct {
ScenarioDefinition
Tags []*Tag `json:"tags"`
Examples []interface{} `json:"examples"`
}
Code that uses Examples is now failing due to not recognised methods.
Scenario:
godog$ git rev-parse HEAD
38c79db503ff4ad0cbb7c1fd04531f243d992c7d
gherkin-go$ git rev-parse HEAD
64f5ebccd5511abba41bf4fa5664faf289c9b102
go versions tested
osx (1.4.3, 1.5.0, 1.6.0)
alpine docker container (1.4.3)
Build output:
/go/src/github.com/DATA-DOG/godog # go build .
# github.com/DATA-DOG/godog
./fmt.go:224: ex.TableBody undefined (type interface {} has no field or method TableBody)
./fmt_pretty.go:136: example.TableBody undefined (type interface {} has no field or method TableBody)
./fmt_pretty.go:176: example.TableHeader undefined (type interface {} has no field or method TableHeader)
./fmt_pretty.go:181: example.Keyword undefined (type interface {} has no field or method Keyword)
./fmt_pretty.go:181: example.Name undefined (type interface {} has no field or method Name)
./fmt_pretty.go:183: example.TableHeader undefined (type interface {} has no field or method TableHeader)
./fmt_pretty.go:190: example.TableBody undefined (type interface {} has no field or method TableBody)
./suite.go:271: example.TableHeader undefined (type interface {} has no field or method TableHeader)
./suite.go:272: example.TableBody undefined (type interface {} has no field or method TableBody)
./suite.go:272: too many errors
Pretty format works fine with Scenario Outlines in the feature file unless there is one (or more) Background steps. When I change the godogs example to look like this:
Feature: eat godogs with an outline
In order to be happy
As a hungry gopher
I need to be able to eat different amounts of godogs
Background: Start with a decent amount
Given there are 12 godogs
Scenario Outline: Eat various numbers of godogs
When I eat
Then there should be remaining
Examples: Leaving some behind
| amount | left |
| 5 | 7 |
| 8 | 4 |
| 11 | 1 |
Examples: Eating them all
| amount | left |
| 12 | 0 |
And then run godog against it with the default (pretty) formatter, I get this panic:
C:\Users\David\Documents\development\godog_outline>bin\godog.exe src\godog_outline.feature
Feature: eat godogs with an outline
In order to be happy
As a hungry gopher
I need to be able to eat different amounts of godogs
Background: Start with a decent amount
Scenario Outline: Eat various numbers of godogs # src\godog_outline.feature:9
When I eat
Then there should be remaining
Examples: Leaving some behind
| amount | left |
| 5 | 7 |
| 8 | 4 |
| 11 | 1 |
panic: runtime error: index out of range
goroutine 17 [running]:
github.com/DATA-DOG/godog.(_pretty).printOutlineExample(0xc08209c000, 0xc0820bc000)
c:/Users/David/Documents/development/godog_outline/src/github.com/DATA-DOG/godog/fmt_pretty.go:190 +0x195f
github.com/DATA-DOG/godog.(_pretty).printStepKind(0xc08209c000, 0xc082084e40)
c:/Users/David/Documents/development/godog_outline/src/github.com/DATA-DOG/godog/fmt_pretty.go:257 +0x132
github.com/DATA-DOG/godog.(_pretty).Undefined(0xc08209c000, 0xc0820884b0)
c:/Users/David/Documents/development/godog_outline/src/github.com/DATA-DOG/godog/fmt_pretty.go:297 +0x207
github.com/DATA-DOG/godog.(_Suite).runStep(0xc08209e0e0, 0xc0820884b0, 0x860028, 0xc08208a100, 0x0, 0x0)
c:/Users/David/Documents/development/godog_outline/src/github.com/DATA-DOG/godog/suite.go:201 +0xb5
github.com/DATA-DOG/godog.(_Suite).runSteps(0xc08209e0e0, 0xc0820ca310, 0x2, 0x2, 0x860028, 0xc08208a100, 0x860028, 0xc08208a100)
c:/Users/David/Documents/development/godog_outline/src/github.com/DATA-DOG/godog/suite.go:245 +0xc1
github.com/DATA-DOG/godog.(_Suite).runOutline(0xc08209e0e0, 0xc0820bc000, 0xc082092240, 0x0, 0x0)
c:/Users/David/Documents/development/godog_outline/src/github.com/DATA-DOG/godog/suite.go:298 +0x74e
github.com/DATA-DOG/godog.(_Suite).runFeature(0xc08209e0e0, 0xc082083700)
c:/Users/David/Documents/development/godog_outline/src/github.com/DATA-DOG/godog/suite.go:324 +0x351
github.com/DATA-DOG/godog.(_Suite).run(0xc08209e0e0)
c:/Users/David/Documents/development/godog_outline/src/github.com/DATA-DOG/godog/suite.go:169 +0xe6
github.com/DATA-DOG/godog.(_runner).run.func1(0xc082088320, 0xc08208b940, 0xc082083700)
c:/Users/David/Documents/development/godog_outline/src/github.com/DATA-DOG/godog/run.go:30 +0x14f
created by github.com/DATA-DOG/godog.(_runner).run
c:/Users/David/Documents/development/godog_outline/src/github.com/DATA-DOG/godog/run.go:36 +0xd9
goroutine 1 [semacquire]:
sync.runtime_Semacquire(0xc08208832c)
c:/go/src/runtime/sema.go:43 +0x2d
sync.(_WaitGroup).Wait(0xc082088320)
c:/go/src/sync/waitgroup.go:126 +0xbb
github.com/DATA-DOG/godog.(_runner).run(0xc082088320, 0xc082088300)
c:/Users/David/Documents/development/godog_outline/src/github.com/DATA-DOG/godog/run.go:38 +0x109
github.com/DATA-DOG/godog.Run(0x6b2238)
c:/Users/David/Documents/development/godog_outline/src/github.com/DATA-DOG/godog/run.go:101 +0x82d
main.main()
C:/Users/David/AppData/Local/Temp/1453177288086389100godog.go:9 +0x2a
exit status 2
We are working on a fix; looks like the problem is in the counting of steps.
As an aside, I have a JUnit-style formatter that I wrote so that we can run our tests in CI. It works OK with outlines so this bug isn't holding us up. Any interest in having me add the JUnit formatter in a pull request? It seems to go along with the comments in bug #4.
For custom output transformations a unified format may be useful..
Would you be interested in a code coverage PR? The numbers are very low:
https://codecov.io/gh/gliptak/godog/branch/codecov1
Maybe I'm missing some test executions?
Probably related to #42
Attempting to run godog in the godog code folder results in the following panic:
Hi,
We have been using Godog for a while with no issues. I ran an update and now get the error:
# _/tmp/godog-1464349241273590437
godog_runner_test.go:13:29: expected ';', found 'IDENT' featureContext
godog_runner_test.go:16:2: expected '}', found 'EOF'
FAIL _/tmp/godog-1464349241273590437 [setup failed]
The error message is very unclear and doesn't point to any of my feature or step files. Also, I absolutely did not change my working godog test code at all - the only change was running go get -u github.com/DATA-DOG/godog/cmd/godog.
Can you advise on how to resolve?
Currently it runs sh -c "go run ..."
update to support windows
Hi,
What about gitter, IRC or slack to talk all together about this framework ?
Thanks
Currently godog.Run parses flags instead of taking configuration options as a parameter. This would be a natural and idiomatic improvement.
Only the command line tool should use flags.
since we run suite in a separate command, it prints the exit status twice on error.
need to fix that in some way
Firsteval, congrats for the good work ! Great project !
I'm currently wondering how are environment variables supported. Typically say we have an authentication feature, and two scenari in it (authentication successfull and authentication failure) but It would be preferable to inject credentials from envrironment for the valid authentication scenario. What would be the best way to do this with godog ?
There is no reason to have an interface here.
Is is possible for me to run my features using the go test command?
I would like to have a test file with maybe a single test function which will invoke the godog runner command with a suite which is prepared by it. Then I wouldn't need to depend on the godog command to run my tests. I can just integrate it will all my other tests.
We can and should run features concurrently, but probably not for pretty format.
Add a concurrency option, which defaults to 1. Not all suites will support that..
Best would be to allow run any format with a concurrency level provided by -c, --concurrency=1 flag.
For pretty format, keep output per feature and flush it when a feature has finished running scenarios (this behavior would only be with a higher than 1 concurrency level).
It would be too complex to handle contexts and variables which may be written synchronously. Will use the approach like beflash but after the #4 is done.
When using go test
to run godog features as described in the readme (using
TestMain
), when the tests are successful, I don't get any output about which
features / steps are run in case of success, but I do get output for example
from a gin http server running as part of the test suite.
Is this intended behavior?
I have the following feature file
Feature: Prove that there is an error with the pretty formatter
Blabla
Blabla
Blabla
Background:
Given the following customers exist
| ID | flag | number |
| 1 | true | 0 |
| 2 | true | 1 |
Scenario Outline: Add two numbers
Given I have number <a>
And I have another number <b>
When I add them together
Then I should receive <c>
Examples:
| a | b | c |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
And a dummy implementation of test
package main
import (
"gopkg.in/cucumber/gherkin-go.v3"
"github.com/DATA-DOG/godog"
)
func theFollowingCustomersExist(arg1 *gherkin.DataTable) error {
return nil
}
func iHaveNumber(arg1 int) error {
return nil
}
func iHaveAnotherNumber(arg1 int) error {
return nil
}
func iAddThemTogether( ) error {
return nil
}
func iShouldReceive(arg1 int) error {
return nil
}
func featureContext(s *godog.Suite) {
s.Step(`^the following customers exist$`, theFollowingCustomersExist)
s.Step(`^I have number (\d+)$`, iHaveNumber)
s.Step(`^I have another number (\d+)$`, iHaveAnotherNumber)
s.Step(`^I add them together$`, iAddThemTogether)
s.Step(`^I should receive (\d+)$`, iShouldReceive)
}
When I run test with -f progress everything passes
➜ features godog -f progress scenario_outline_and_background_error.feature
................................... 35
7 scenarios (7 passed)
35 steps (35 passed)
741.667µs
Using pretty formatter there is a weird failure:
➜ features godog -f pretty scenario_outline_and_background_error.feature
Feature: Prove that there is an error with the pretty formatter
Blabla
Blabla
Blabla
Background:
Given the following customers exist # main.theFollowingCustomersExist
| ID | flag | number |
| 1 | true | 0 |
| 2 | true | 1 |
Scenario Outline: Add two numbers # scenario_outline_and_background_error.feature:13
Given I have number <a> # main.iHaveNumber
And I have another number <b> # main.iHaveAnotherNumber
When I add them together # main.iAddThemTogether
Then I should receive <c> # main.iShouldReceive
Examples:
| a | b | c |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
--- Failed scenarios:
scenario_outline_and_background_error.feature:15
7 scenarios (6 passed, 1 failed)
36 steps (35 passed, 1 failed)
779.458µs
If you have only 4 examples, the pretty formatter works as expected
Using go 1.7
go version
go1.7 darwin/amd64
Hi,
When launching the test in concurrency, we don't know in which position the test is in the queue.
This kind of feature is for instance used in parallel_test (https://github.com/grosser/parallel_tests) with the env variable TEST_ENV_NUMBER. This is slightly difference though, in parallel this information is set in a environment variable as different processes are launched. In godog it would more linked to the Suite I guess.
Do you think it's a good idea to add that in Godog, or would you prefer that the testers take care about that ?
Thanks,
Then there should be an event created on "GaddCommander" in Customer.io with the contents:
"""
...
"""
func thereShouldBeAnEventCreatedOninCustomerioWithTheContents(arg1 string, arg2 *gherkin.DocString) error {
return godog.ErrPending
}
func featureContext(s *godog.Suite) {
s.Step(`^there should be an event created on "([^"]*)" in Customer\\.io with the contents:$`, thereShouldBeAnEventCreatedOninCustomerioWithTheContents)
}
Expected: Customer\\.io
should be Customer\.io
I am logging this for now as FYI. I might create a PR for it later if I have the time.
Hi,
I'm currently working on building some tests for an authenticating proxy, and i'm a bit stuck about how to pass results between stages of the test. At the moment i'm using a sort of "feature" struct, which i'm populating and consuming information from, is this the "idiomatic" way? Or is there some way i'm unaware of?
For instance, I want to test my implementationg of the OAUTH2 flow, so there's a lot of
Scenario: A Request made
Given an upstream server that pings
And an ADFS server that is preauthenticated
And a client
When I start a proxy server configured for the ADFS server
And I request /Index.html from the proxy server
Then I should be redirected to the ADFS login URL
When I follow the redirect
Then I should be redirected to the callback URL with a query parameter
When I follow the redirect
Then I should be redirected to the original page (relative URL)
Then I should get an OK response with index.html in the body
Is there some internal godog context? Any help or guidance would be really appreciated. Thanks
I am getting a compilation error when running godog
on example folder.
Go version:
$ go version
go version go1.7.4 darwin/amd64
I installed godog:
$ go get -u github.com/DATA-DOG/godog
Then I go into the godogs example directory:
$ cd $GOPATH
$ cd src/go/src/github.com/DATA-DOG/godog/examples/godogs
And run godog:
$ godog
failed to compile testmain package:
I have a feature and test file in the same directory as the main package for an application that I wanted to test, but when I run godog . it fails with a bunch of "imported and not used" errors.
One for each the import statements.
From looking at the code it seems there is an issue with the merge function where it does not remove all of the imports, which were needed for my main function.
In my case I have a single main function like your cmd/godog package which calls library type package functions but does some flags type parsing.
If I move the feature file and its test file to another directory it works, my use case is for running api tests.
I have been able to re-create by making two alterations to your api example @ https://github.com/DATA-DOG/godog/blob/master/examples/api/api.go
Since the main method is removed and it does not remove the "os" import I get
/tmp/1459347300796577005godog.go:11: imported and not used: "os"
Thanks in advance
Pat
Having used Behave (python) and Cucumber (Java), I really appreciate Godog, which I have integrated into a Go project.
I have one problem with it: When a problem occurs (especially an error raised), only the message is displayed, leaving me with no idea where the issue actually occurred:
runtime error: index out of range
Is there a way to tell godog to be more verbose so I can work out what index was out of range?
The only meaningful option now is to panic, would be better to handle errors for the suite correctly and the golang way
There's no easy way to setup a (new) project with godog
.
It would be nice to have a --init
-flag like we have on cucumber-ruby
to setup a (new) project with cucumber-godog.
godog --init
We are looking to leverage godog for our integration testing. We also are looking leverage the xray plugin in jira. xray supports importing of test results from cucumber or xray formats.
http://confluence.xpand-addons.com/display/XRAY/Import+Execution+Results+-+REST
Any plans to support additional formats?
given
Feature:
Background:
Given very long string here we cannot imagine how long
Scenario:
Given short
leads to panic in pretty printer.
The following patch fixes it for me:
--- a/fmt_pretty.go
+++ b/fmt_pretty.go
@@ -256,6 +256,9 @@ func (f *pretty) printStepKind(res *stepResult) {
// first step of scenario, print header and calculate comment position
case f.scenario != nil && f.steps == len(f.scenario.Steps):
f.commentPos = f.longestStep(f.scenario.Steps, f.length(f.scenario))
+ if bgLength := f.longestStep(f.feature.Background.Steps, f.length(f.feature.Background)); bgLength > f.commentPos {
+ f.commentPos = bgLength
+ }
text := s(f.indent) + bcl(f.scenario.Keyword+": ", white) + f.scenario.Name
text += s(f.commentPos-f.length(f.scenario)+1) + f.line(f.scenario.Location)
fmt.Println("\n" + text)
I recently updated to v0.4.3 and noticed that adding the --stop-on-failure flag doesn't stop executing when a scenario fails.
Currently godog builds a test file from current directory _.go file sources. It may be possible to build dependent packages with __test.go* files and link them including a dependent package suite contexts for godog.
It may require some hard work to achieve this, but very useful to have in the future, instead of running godog per each package.
Follow the specification for tag filter: http://behat.readthedocs.org/en/v2.5/guides/6.cli.html#gherkin-filters
My current environment
$ go version
go version go1.6.2 linux/amd64
$ godog -version
Godog version is: v0.5.0
I have created a feature with a scenario outline, I have added 2 examples sucessfully but when I try to add a third example I get an "index out of range" runtime error
Seems to be an issue with the output printer, as it continues to execute the test cases.
You can re-created with the following
I have re-created with this file (Failing with the 3rd example), note I have no _test.go file as not needed to re-created the error
sample.feature
Feature: demo
Background:
Given Something
Scenario Outline: making http call
When I make "<method>" on "<path>"
Then I should get status code <status-code>
Examples:
| description | method | path | status-code |
| Fails for post on /health 1 | POST | /health | 405 |
| Fails for post on /health 2 | POST | /health | 405 |
| Fails for post on /health 3 | POST | /health | 405 |
When I run
cd go/src/datadoginv
godog .
I get this
Feature: demo
Background:
Given Something
Scenario Outline: making http call # sample.feature:4
When I make "<method>" on "<path>"
Then I should get status code <status-code>
Examples:
| description | method | path | status-code |
| Fails for post on /health 1 | POST | /health | 405 |
| Fails for post on /health 2 | POST | /health | 405 |
| Fails for post on /health 3 | POST | /health | 405 |
panic: runtime error: index out of range
goroutine 1 [running]:
panic(0x6774a0, 0xc82000e0b0)
/usr/local/go-versions/go1.6.2/src/runtime/panic.go:481 +0x3e6
github.com/DATA-DOG/godog.(*pretty).printOutlineExample(0xc820076fc0, 0xc820120000)
/home/pmcgrath/go/src/github.com/DATA-DOG/godog/fmt_pretty.go:187 +0x19a2
github.com/DATA-DOG/godog.(*pretty).printStepKind(0xc820076fc0, 0xc8200bf0c0)
/home/pmcgrath/go/src/github.com/DATA-DOG/godog/fmt_pretty.go:295 +0x15a7
github.com/DATA-DOG/godog.(*pretty).Undefined(0xc820076fc0, 0xc820012cd0)
/home/pmcgrath/go/src/github.com/DATA-DOG/godog/fmt_pretty.go:335 +0x200
github.com/DATA-DOG/godog.(*Suite).runStep(0xc8200ac2a0, 0xc820012cd0, 0x7f328f1e3028, 0xc82000f8c0, 0x0, 0x0)
/home/pmcgrath/go/src/github.com/DATA-DOG/godog/suite.go:202 +0xa6
github.com/DATA-DOG/godog.(*Suite).runSteps(0xc8200ac2a0, 0xc82011f090, 0x2, 0x2, 0x7f328f1e3028, 0xc82000f8c0, 0x7f328f1e3028, 0xc82000f8c0)
/home/pmcgrath/go/src/github.com/DATA-DOG/godog/suite.go:246 +0xba
github.com/DATA-DOG/godog.(*Suite).runOutline(0xc8200ac2a0, 0xc820120000, 0xc82005a720, 0x0, 0x0)
/home/pmcgrath/go/src/github.com/DATA-DOG/godog/suite.go:310 +0x81c
github.com/DATA-DOG/godog.(*Suite).runFeature(0xc8200ac2a0, 0xc820122000)
/home/pmcgrath/go/src/github.com/DATA-DOG/godog/suite.go:336 +0x34a
github.com/DATA-DOG/godog.(*Suite).run(0xc8200ac2a0)
/home/pmcgrath/go/src/github.com/DATA-DOG/godog/suite.go:170 +0xdf
github.com/DATA-DOG/godog.(*runner).run(0xc8200bed00, 0xc8200bed00)
/home/pmcgrath/go/src/github.com/DATA-DOG/godog/run.go:58 +0xe6
github.com/DATA-DOG/godog.Run(0x738cf0, 0xc820000180)
/home/pmcgrath/go/src/github.com/DATA-DOG/godog/run.go:118 +0x5c2
main.main()
/tmp/godog-1468325360368887697/_testmain.go:10 +0x23
app.go
package main
import "fmt"
func main() {
fmt.Print("Dummy app")
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.