-
Notifications
You must be signed in to change notification settings - Fork 274
ambiguous step def detection akin to cucumber jvm #636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1b8db25
added basic detection for ambiguous steps, but causes an error and no…
Johnlon a65a8a1
added initial support for detection of ambiguous steps - further work…
Johnlon dadf69a
added suite_context_test and also introduced missing 'ambiguous' stat…
Johnlon 6f948b0
update CHANGELOG for ambiguous step defs
Johnlon f448d8d
missed file from commit
Johnlon 8b73087
added internal/formatters/fmt_multi_test.go
Johnlon 1d850eb
add tests for other peoples code
Johnlon 9af0995
added "ambigous" to the help text
Johnlon 078a136
tests
Johnlon d0bfcea
added some more tests for attachments
Johnlon a6f9c2e
Update internal/flags/flags.go
Johnlon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package godog | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestAttach(t *testing.T) { | ||
|
|
||
| ctx := context.Background() | ||
|
|
||
| ctx = Attach(ctx, Attachment{Body: []byte("body1"), FileName: "fileName1", MediaType: "mediaType1"}) | ||
| ctx = Attach(ctx, Attachment{Body: []byte("body2"), FileName: "fileName2", MediaType: "mediaType2"}) | ||
|
|
||
| attachments := Attachments(ctx) | ||
|
|
||
| assert.Equal(t, 2, len(attachments)) | ||
|
|
||
| assert.Equal(t, []byte("body1"), attachments[0].Body) | ||
| assert.Equal(t, "fileName1", attachments[0].FileName) | ||
| assert.Equal(t, "mediaType1", attachments[0].MediaType) | ||
|
|
||
| assert.Equal(t, []byte("body2"), attachments[1].Body) | ||
| assert.Equal(t, "fileName2", attachments[1].FileName) | ||
| assert.Equal(t, "mediaType2", attachments[1].MediaType) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| package formatters | ||
|
|
||
| import ( | ||
| "errors" | ||
| "testing" | ||
|
|
||
| "github.com/cucumber/godog/formatters" | ||
| messages "github.com/cucumber/messages/go/v21" | ||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| var ( | ||
| mock = DummyFormatter{} | ||
| base = BaseFormatter{} | ||
|
|
||
| document = &messages.GherkinDocument{} | ||
| str = "theString" | ||
| byt = []byte("bytes") | ||
| pickle = &messages.Pickle{} | ||
| step = &messages.PickleStep{} | ||
| definition = &formatters.StepDefinition{} | ||
| err = errors.New("expected") | ||
| ) | ||
|
|
||
| // TestRepeater tests the delegation of the repeater functions. | ||
| func TestRepeater(t *testing.T) { | ||
|
|
||
| mock.tt = t | ||
| f := make(repeater, 0) | ||
| f = append(f, &mock) | ||
| f = append(f, &mock) | ||
| f = append(f, &base) | ||
|
|
||
| f.Feature(document, str, byt) | ||
| f.TestRunStarted() | ||
| f.Pickle(pickle) | ||
| f.Defined(pickle, step, definition) | ||
| f.Passed(pickle, step, definition) | ||
| f.Skipped(pickle, step, definition) | ||
| f.Undefined(pickle, step, definition) | ||
| f.Failed(pickle, step, definition, err) | ||
| f.Pending(pickle, step, definition) | ||
| f.Ambiguous(pickle, step, definition, err) | ||
|
|
||
| assert.Equal(t, 2, mock.CountFeature) | ||
| assert.Equal(t, 2, mock.CountTestRunStarted) | ||
| assert.Equal(t, 2, mock.CountPickle) | ||
| assert.Equal(t, 2, mock.CountDefined) | ||
| assert.Equal(t, 2, mock.CountPassed) | ||
| assert.Equal(t, 2, mock.CountSkipped) | ||
| assert.Equal(t, 2, mock.CountUndefined) | ||
| assert.Equal(t, 2, mock.CountFailed) | ||
| assert.Equal(t, 2, mock.CountPending) | ||
| assert.Equal(t, 2, mock.CountAmbiguous) | ||
|
|
||
| } | ||
|
|
||
| type BaseFormatter struct { | ||
| *Base | ||
| } | ||
|
|
||
| type DummyFormatter struct { | ||
| *Base | ||
|
|
||
| tt *testing.T | ||
| CountFeature int | ||
| CountTestRunStarted int | ||
| CountPickle int | ||
| CountDefined int | ||
| CountPassed int | ||
| CountSkipped int | ||
| CountUndefined int | ||
| CountFailed int | ||
| CountPending int | ||
| CountAmbiguous int | ||
| } | ||
|
|
||
| // SetStorage assigns gherkin data storage. | ||
| // func (f *DummyFormatter) SetStorage(st *storage.Storage) { | ||
| // } | ||
|
|
||
| // TestRunStarted is triggered on test start. | ||
| func (f *DummyFormatter) TestRunStarted() { | ||
| f.CountTestRunStarted++ | ||
| } | ||
|
|
||
| // Feature receives gherkin document. | ||
| func (f *DummyFormatter) Feature(d *messages.GherkinDocument, s string, b []byte) { | ||
| assert.Equal(f.tt, document, d) | ||
| assert.Equal(f.tt, str, s) | ||
| assert.Equal(f.tt, byt, b) | ||
| f.CountFeature++ | ||
| } | ||
|
|
||
| // Pickle receives scenario. | ||
| func (f *DummyFormatter) Pickle(p *messages.Pickle) { | ||
| assert.Equal(f.tt, pickle, p) | ||
| f.CountPickle++ | ||
| } | ||
|
|
||
| // Defined receives step definition. | ||
| func (f *DummyFormatter) Defined(p *messages.Pickle, s *messages.PickleStep, d *formatters.StepDefinition) { | ||
| assert.Equal(f.tt, pickle, p) | ||
| assert.Equal(f.tt, s, step) | ||
| assert.Equal(f.tt, d, definition) | ||
| f.CountDefined++ | ||
| } | ||
|
|
||
| // Passed captures passed step. | ||
| func (f *DummyFormatter) Passed(p *messages.Pickle, s *messages.PickleStep, d *formatters.StepDefinition) { | ||
| assert.Equal(f.tt, pickle, p) | ||
| assert.Equal(f.tt, s, step) | ||
| assert.Equal(f.tt, d, definition) | ||
| f.CountPassed++ | ||
| } | ||
|
|
||
| // Skipped captures skipped step. | ||
| func (f *DummyFormatter) Skipped(p *messages.Pickle, s *messages.PickleStep, d *formatters.StepDefinition) { | ||
| assert.Equal(f.tt, pickle, p) | ||
| assert.Equal(f.tt, s, step) | ||
| assert.Equal(f.tt, d, definition) | ||
|
|
||
| f.CountSkipped++ | ||
| } | ||
|
|
||
| // Undefined captures undefined step. | ||
| func (f *DummyFormatter) Undefined(p *messages.Pickle, s *messages.PickleStep, d *formatters.StepDefinition) { | ||
| assert.Equal(f.tt, pickle, p) | ||
| assert.Equal(f.tt, s, step) | ||
| assert.Equal(f.tt, d, definition) | ||
|
|
||
| f.CountUndefined++ | ||
| } | ||
|
|
||
| // Failed captures failed step. | ||
| func (f *DummyFormatter) Failed(p *messages.Pickle, s *messages.PickleStep, d *formatters.StepDefinition, e error) { | ||
| assert.Equal(f.tt, pickle, p) | ||
| assert.Equal(f.tt, s, step) | ||
| assert.Equal(f.tt, d, definition) | ||
| assert.Equal(f.tt, err, e) | ||
|
|
||
| f.CountFailed++ | ||
| } | ||
|
|
||
| // Pending captures pending step. | ||
| func (f *DummyFormatter) Pending(p *messages.Pickle, s *messages.PickleStep, d *formatters.StepDefinition) { | ||
| assert.Equal(f.tt, pickle, p) | ||
| assert.Equal(f.tt, s, step) | ||
| assert.Equal(f.tt, d, definition) | ||
|
|
||
| f.CountPending++ | ||
| } | ||
|
|
||
| // Ambiguous captures ambiguous step. | ||
| func (f *DummyFormatter) Ambiguous(p *messages.Pickle, s *messages.PickleStep, d *formatters.StepDefinition, e error) { | ||
| assert.Equal(f.tt, pickle, p) | ||
| assert.Equal(f.tt, s, step) | ||
| assert.Equal(f.tt, d, definition) | ||
| f.CountAmbiguous++ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.