Skip to content
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

Code suggestion for Cucumber Expressions #57

Open
uo9qsuf opened this issue Nov 30, 2022 · 4 comments
Open

Code suggestion for Cucumber Expressions #57

uo9qsuf opened this issue Nov 30, 2022 · 4 comments

Comments

@uo9qsuf
Copy link

uo9qsuf commented Nov 30, 2022

Code suggestion for Cucumber Expressions. At moment I get only suggestion in regex format.

testGherkin(): No CucumberSwift expression found that matches this step. Try adding the following Swift code to your step implementation file: 
When("^I execute the three \\{(\\d+)\\} tests$") { matches, _ in
    let integer = matches[1]
}

Solution can be a mode which the developer can set in the info plist for change from regex to Cucumber Expressions. On this way we can remove the "as CucumberExpression" in the steps.

@Tyler-Keith-Thompson If you can say me there I can at this support I can help you.

@Tyler-Keith-Thompson
Copy link
Owner

Tyler-Keith-Thompson commented Nov 30, 2022

So I can certainly add step suggestions that make use of expressions. Could potentially even get clever and find a way to give both as an option. I'll add that as an enhancement request.

That said, a plist setting to default to expressions won't work because a plist is runtime configuration and expressions vs regex is a compile-time concern.

It could be solved with codegen or clever imports, but I have a different solution in mind.

With regex literals added to Swift and supported by CucumberSwift we can just make a breaking change. Strings can be considered expressions and regex literals would of course be regex. This lines up well with other Cucumber implementations in other languages.

My only hesitation is I'm uncertain if most enterprise consumers are prepared to use regex literals or refactor all existing CucumberSwift tests to use expressions. In an ideal world I could use fixits to have the compiler do the heavy lifting.

Give me some time to ponder how to best support those with slower moving processes, but I think we can make the change so you can quit using "as CucumberExpression"

@Tyler-Keith-Thompson
Copy link
Owner

Update: I've released a version that deprecates the string-based function. I'm gonna leave that for maybe a month and then I'll change behavior so that strings use expressions and regex literals work for regex.

As far as expression code suggestions I'll add that to the backlog.

@uo9qsuf
Copy link
Author

uo9qsuf commented Dec 12, 2022

@Tyler-Keith-Thompson call thank you. I don't need anymore to case the expressions.

@Tyler-Keith-Thompson
Copy link
Owner

Update: v4.0.5 removes the requirement to use "as CucumberExpression".

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

No branches or pull requests

2 participants