Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt
- Step text is added to "step is undefined" error - ([669](https://github.com/cucumber/godog/pull/669) - [vearutop](https://github.com/vearutop))

### Fixed
- fix(errors): fix(errors): Fix expected Step argument count for steps with `context.Context` ([679](https://github.com/cucumber/godog/pull/679) - [tigh-latte](https://github.com/tigh-latte))
- fix(formatter): On concurrent execution, execute formatter at end of Scenario - ([645](https://github.com/cucumber/godog/pull/645) - [tigh-latte](https://github.com/tigh-latte))

## [v0.15.0]
Expand Down
2 changes: 1 addition & 1 deletion internal/models/stepdef.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (sd *StepDefinition) Run(ctx context.Context) (context.Context, interface{}
}

if len(sd.Args) < numIn {
return ctx, fmt.Errorf("%w: expected %d arguments, matched %d from step", ErrUnmatchedStepArgumentNumber, typ.NumIn(), len(sd.Args))
return ctx, fmt.Errorf("%w: expected %d arguments, matched %d from step", ErrUnmatchedStepArgumentNumber, numIn, len(sd.Args))
}

for i := 0; i < numIn; i++ {
Expand Down
20 changes: 20 additions & 0 deletions internal/models/stepdef_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,26 @@ func TestArgumentCountChecks(t *testing.T) {
assert.Nil(t, err)
}

func TestArgumentCountChecksWithContext(t *testing.T) {
wasCalled := false
fn := func(ctx context.Context, a int, b int) {
wasCalled = true
}

def := &models.StepDefinition{
StepDefinition: formatters.StepDefinition{
Handler: fn,
},
HandlerValue: reflect.ValueOf(fn),
}

def.Args = []interface{}{"1"}
_, err := def.Run(context.Background())
assert.False(t, wasCalled)
assert.Equal(t, `func expected more arguments than given: expected 2 arguments, matched 1 from step`, err.(error).Error())
assert.True(t, errors.Is(err.(error), models.ErrUnmatchedStepArgumentNumber))
}

func TestShouldSupportIntTypes(t *testing.T) {
var aActual int64
var bActual int32
Expand Down