Skip to content

feat: support bool type parameter in step functions#761

Open
StevenHuangYH wants to merge 2 commits into
cucumber:mainfrom
StevenHuangYH:feat/support-bool-parameter
Open

feat: support bool type parameter in step functions#761
StevenHuangYH wants to merge 2 commits into
cucumber:mainfrom
StevenHuangYH:feat/support-bool-parameter

Conversation

@StevenHuangYH

Copy link
Copy Markdown

What's changed?

This PR adds support for bool as a parameter type in step handler functions.

Previously, using bool in a step function would result in:

func has unsupported parameter type: the parameter 0 type bool is not supported

Now you can write step definitions like:

ctx.Step(`^feature is enabled: (true|false)$`, func(enabled bool) error {
    // enabled is automatically parsed from the string
    ...
})

How it works

Uses strconv.ParseBool which accepts the following string values:

  • true: "1", "t", "T", "TRUE", "true", "True"
  • false: "0", "f", "F", "FALSE", "false", "False"

Changes

  • internal/models/stepdef.go: Added reflect.Bool case in the Run() type switch
  • internal/models/stepdef_test.go: Added TestShouldSupportBoolType test and updated the invalid-type test to reflect that bool is now supported

Related

Related to #747 (optional parameters for int/uint/float types)

Copilot AI review requested due to automatic review settings July 11, 2026 19:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class support for bool parameters in step handler functions, enabling automatic conversion of matched step arguments into Go booleans during step execution.

Changes:

  • Extend StepDefinition.Run() argument conversion to handle reflect.Bool via strconv.ParseBool.
  • Add a dedicated test validating bool parsing and invalid bool conversion errors.
  • Update the “invalid handler param” test to no longer treat bool as an unsupported parameter type.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
internal/models/stepdef.go Adds bool argument parsing using strconv.ParseBool in the step invocation conversion switch.
internal/models/stepdef_test.go Adds coverage for bool parameters and updates unsupported-type expectations accordingly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/models/stepdef_test.go Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants