Code Monkey home page Code Monkey logo

Comments (3)

Tyler-Keith-Thompson avatar Tyler-Keith-Thompson commented on June 7, 2024

I will try and play with some options to give you a better answer, but for right this second you seem to be using a mixture of the DSL and feature files. I really recommend only using one. Your current code isn't quite supported as is.

If you're going to use the DSL, you don't need to use the Given/When/Then methods that take a string or regex, for example

Feature("Delete an image") {
    Scenario("Delete an image locally") {
        Given(the: userHasALocallyStoredImage())
        When(the: imageIsDeleted())
        Then(the: localStoreShouldBeEmpty())
    }
}

func userHasALocallyStoredImage() { XCTFail("Implement the step") }
func imageIsDeleted() { XCTFail("Implement the step") }
func localStoreShouldBeEmpty { XCTFail("Implement the step") }

If you're going with .feature files, I don't recommend wrapping your steps in the Feature/Scenario DSL. So instead do:

func steps() {
    Given("the user has a local stored image" as CucumberExpression) { _, _ in }
    When("he delete the image" as CucumberExpression) { _, _ in }
    Then("the local store should be empty" as CucumberExpression) { _, _ in }
}

It's possible that some of what you're seeing with all those duplicate entries is really a byproduct of mixing and matching the 2 methods of executing Gherkin.

That said, I am sadly very limited here. Apple doesn't really give access to this in a sane way. The only way CucumberSwift is able to show up in that navigator at all is to use the Objective-C runtime to dynamically create classes. The | character was used to delineate between features and scenarios in those test case names. I'll leave this issue open so I can explore a bit and see if we can do better.

from cucumberswift.

bitsmakerde avatar bitsmakerde commented on June 7, 2024

@Tyler-Keith-Thompson thank you for this nice answer.

But both ways look for me not so "sexy" at the moment.

Why I think so. I like to see a one to one relation for the .feature to the source code. But in both ways something is missing like the Feature / Scenario or the Given/When/Then description text.

One other point I find out is, that I can't start a Scenario separate.

What do you think if a Scenario is warp inside a func test_... so Xcode can find this a test run it and can show it automatic in the navigator. For this case for me its fine only to see the scenario is failed and being inspect the detail I see there its fails.

I try the first way, but for it not really work. CucumberSwift says's alway not implementation for my feature.

Will it be a problem if I stay by my code?

from cucumberswift.

bitsmakerde avatar bitsmakerde commented on June 7, 2024

I comment the duplicate code out. But it not looking nice.

  // swiftlint:disable todo
  // TODO: - Feature("Delete an image")
  // MARK: - Scenario("Delete an image locally")
        
        Given("the user has selected an image to save" as CucumberExpression) { _, _ in
            ...
        }
        
        When("the image is saved to the selected location on the device's storage" as CucumberExpression) { _, _ in
            ...
        }
        
        Then("the image becomes persistent on the phone" as CucumberExpression) { _, _ in
           ...
        }

This looks like this in Xcode

image

from cucumberswift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.