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

No error when a Gherkin statement doesn't match any CucumberSwift expressions #36

Closed
hkingverily opened this issue Feb 2, 2022 · 9 comments
Labels
enhancement New feature or request

Comments

@hkingverily
Copy link

Describe the bug
No error when a Gherkin statement doesn't match any CucumberSwift expressions

To Reproduce
Steps to reproduce the behavior:

  1. Add a Gherkin statement
  2. No CucumberSwift expression that matches the Gherkin statement

Expected behavior
Error for Gherkin statement with no matching CucumberSwift expressions

Additional context

  • CucumberSwift Version: 3.3.6
@alexvoss
Copy link

alexvoss commented Apr 19, 2022

Either a warning or an error on unmatched steps would be good. I am trying out CucumberSwift but am only getting testGherkin() in my test results. None of my scenarios run and I have nothing to go by as to why this might be the case.

The process described for generating step stubs does not seem to work. I had a quick look at the sources and there does not seem to be a class GenerateStubsIfNecessary? Has this functionality been dropped?

Update: once tests are working this also works. Bit of a catch-22 tho?
I spoke too soon. GenerateStubsIfNecessarydoes show up but where is the attachment that gives me the stubs?

This is a shame as CucumberSwift seems to be the hottest contender for doing BDD in Swift.

@alexvoss
Copy link

Ok, my problem was that I did not have the Features directory added to the UITest Target. I assume CucumberSwift did not find any .feature files but passed testGherkin()?

@Tyler-Keith-Thompson
Copy link
Owner

Ok, my problem was that I did not have the Features directory added to the UITest Target. I assume CucumberSwift did not find any .feature files but passed testGherkin()?

Yeah, in order to make it so that consumers had to do as little as possible CucumberSwift ships with a test called testGherkin. It actually uses execution of that test to do a variety of different tasks at runtime.

Previous versions used ideas like Principal Class in the info.plist or a +load() method, but it all required consumers to do more.

@Tyler-Keith-Thompson
Copy link
Owner

However, many people have run into the issue of not having the features directory correctly added and I think there's a reasonable way CucumberSwift could report no feature files found. Let me add that to the todo along with this issue.

@alexvoss
Copy link

Thanks, great. Would it be possible to get something like a verbose output option? I have tests running but only some of them actually execute code. That is, I have a scenario outline and the expected tests are generated and appear in the test navigator but the step code is never executed, not even for the Given step. I set breakpoints to check and they did not get hit. I am sure I am making beginner mistakes somewhere - it would be good to be able to see what CucumberSwift is and is not doing.

@Tyler-Keith-Thompson
Copy link
Owner

To keep issues clearly separated I've created #41 and #42 to capture some of the ideas in here. Meanwhile the original point of this issue will be prioritized and addressed.

@Tyler-Keith-Thompson
Copy link
Owner

Adding this feature actually gave a MUCH better opportunity to give generated step stubs to consumers.

Here are some screenshots that showcase how it works
Screen Shot 2022-04-20 at 4 39 38 PM
Screen Shot 2022-04-20 at 4 39 41 PM

If consumers do not desire this behavior there's a somewhat undocumented swift feature they can use to disable it:

extension CucumberTest {
    @_dynamicReplacement(for: failStep)
    func replacementFailStep(_ issue: XCTIssue) { }
}

@Tyler-Keith-Thompson
Copy link
Owner

NOTE: This also works when giving you generated code for known types. In this case a doc string (notice the generated code shows you how to access that doc string)

Screen Shot 2022-04-20 at 4 42 50 PM

@Tyler-Keith-Thompson
Copy link
Owner

Tyler-Keith-Thompson commented Apr 20, 2022

Released in 3.3.10

CucumberSwift Kanban automation moved this from In progress to Done Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

3 participants