Tyler-Keith-Thompson / CucumberSwift

A lightweight swift Cucumber implementation
https://tyler-keith-thompson.github.io/CucumberSwift/documentation/cucumberswift/
MIT License
74 stars 19 forks source link

Steps separated as rT and Command line support #54

Closed ysnnzlcn closed 1 year ago

ysnnzlcn commented 1 year ago

Hi, i am trying to implement this to my project but there are some concepts that i can't understand. I read the docs and checked the CucumberSwiftSample but it didnt help.

How i use it:

Screen Shot 2022-11-02 at 10 12 36

As you can see in the image I defined steps inside the test func and expect them to be grouped in the test results with a big T but every single step looks like they are a separate test. My questions are:

Tyler-Keith-Thompson commented 1 year ago

Apologies for the late response, I've had some surgeries that took me out of commission for quite a while.

Q: Is there a way to group them under the func name? Why does every step look like another test case? A: Because XCTest is not even remotely friendly to tie into. The only way to do it is to use the Objective-C runtime and dynamically create classes. So that's what CucumberSwift does. This causes all of the behaviors you've witnessed. There isn't a way to group them per se...but there are 3 workarounds.

Q: Is it possible to run any test seperately? Right now if i run any test separately, it gets succeeded without running cucumber steps but if i run them all (cmd+U) cucumber works. A: Yeah, that's because the classes are dynamically created, and so rerun can't actually find the class to run. There is a workaround with the shouldRun method. NOTE: This will be moved to DocC when I have time. These docs show how you can run by line number, but you have the scenario object, so run by whatever criteria you want, tags, line, scenario title, whatever.

Q: When i run tests from the terminal and CI/CD, cucumber also doesn't work. Is there a documentation to follow for this implementation? A: That's weird...I run by CI/CD all the time. In fact this whole library can only deploy if that works. I'd need way more info on what you're trying to do. Short answer: If you use xcodebuild to run your tests, you should be fine.

ysnnzlcn commented 1 year ago

@Tyler-Keith-Thompson No problem man, thank you for responding. I have handled the terminal issue and will try your suggestions. I will close this issue and reopen it if i get stuck in the future. Thanks again 🙏