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

Code suggestion should fail without changes #58

Open bitsmakerde opened 1 year ago

bitsmakerde commented 1 year ago

@Tyler-Keith-Thompson I think it can be good behavior if an empty Given, When, Then should be failed. At the moment I write an empty test and its not fail.

I think in TDD should a empty test fail.

Here some possible solutions:

  1. in the code suggestion is automatic an placeholder code like this XCTFail("Empty test, please add code to your test")
  2. The Framework search for empty test an create a failure
  3. The Framework throw only a warning that the test is empty, but here the TDD is not complete fulfill.

Thank you

Tyler-Keith-Thompson commented 1 year ago

So for the generated step stubs I can totally add an XCTFail, that seems like a great addition.

I'm hesitant to do more for a couple reasons. The first is that Gherkin is first and foremost meant to be a human readable specification. That means that there are times when people write Gherkin for context, but don't expect any code to execute. This has been discussed before and there are times (especially with a Given step) where it's really just about giving context to the reader.

Okay, getting past all that for a minute, it's impractical to detect whether a closure contains any executable instructions. The best I could conceive of it to use swift-syntax to try and parse the Swift code at the call site and determine it that way. That'd add dependencies and overhead that we realistically just don't want.

bitsmakerde commented 1 year ago

Ok I understand. Perhaps it make only sense to add this check or Stub to the Then. Because here should be a Assert or something. Without this it's only a test which is testing nothing 😉