top | item 7989419

Sleipnir: BDD-style framework for Swift

27 points| AlexDenisov | 11 years ago |github.com | reply

15 comments

order
[+] zackmorris|11 years ago|reply
For anyone curious: Behavior-Driven Development (BDD) is a business logic alternative to Test-Driven Development (TDD). It uses more of a conversational tone to spell out tests, so you write what you would like the app to do rather than sitting there scratching your head trying to figure out which tests to write. So it places emphasis on the "what" you want the program to do, and fill in the "how" behind the scenes. You can actually write all of your BDD gherkin and test fly your app with known inputs and outputs and then add the logic for arbitrary input and output later. Here is an example implementation for PHP:

http://codeception.com

[+] rubiquity|11 years ago|reply
Oh, boy. As usual anyone trying to define the difference between BDD and TDD gets it wrong. The difference between TDD and BDD isn't the tone in which you describe your test examples. The difference lies in the depth of the layer you start developing a system (or subsystem) at. Some refer to this as Outside-In versus Inside-Out. BDD and TDD have nothing to do with DSLs or the tone in which you describe your test examples.

As an example, I practice BDD but I use MiniTest, a "TDD" testing library.

[+] The_Pherocity|11 years ago|reply
I wouldn't call this a BDD framework yet. It's speckled with both standard assertions and semantic assertions, and an "It" function that simply takes a block and a string. I can replicate this with using underscores in my test function names and avoid the complexity. Not trying to be a jerk, but what we should be driving for is something closer to:

    func Describe("The system I want to Test"){
        When("I click the red button")
        Then("I should see the light turn on")
        And("I should see 4 lights")
    }

    func Step("I click the red button"){
       buttons["red"].click
    }

    func Step("I should see the light turn on"){
       lights.on.should().be_true
    }

    func Step("I should see (\d+) lights"){
        lights.count.should().be(4)
    }
[+] 21echoes|11 years ago|reply
it depends on what you consider "BDD". The linked library is nearly identical to Cedar ( https://github.com/pivotal/cedar ), which is, in turn, nearly identical to rspec ( http://rspec.info/ ). Both of these libraries are very much considered BDD. You seem to be advocating something closer to cucumber/gherkin?
[+] tsenkov|11 years ago|reply
It's so nice to see how new ecosystems emerge. Looking forward to many more frameworks and tools for Swift.
[+] woah|11 years ago|reply
I just want to say: Awesome logo.
[+] MaxGabriel|11 years ago|reply
Agreed. Did you do the logo yourself?