Skip to content

Instantly share code, notes, and snippets.

@fivetanley
Created August 27, 2012 17:06
Show Gist options
  • Save fivetanley/3490439 to your computer and use it in GitHub Desktop.
Save fivetanley/3490439 to your computer and use it in GitHub Desktop.
Cucumber Example
#Brittle Example
Feature: Automatically Update the Chat View
Users should not have to refresh their browser to see the latest messages.
Scenario: I send a message
Given I am on the chatsite
#Lower-level. Describes exact actions a user will execute in his/her browser.
When I fill out the message body with "Hi everyone"
And I click the "Send" button
Then I should see "<example_username>Hi everyone" in the ChatView
#Higher level example
Feature: Automatically Update the Chat View
Users should not have to refresh their browser to see the latest messages.
Scenario: I send a message
Given I am on the chatsite
When I send a Message #very high level, does not explain user's browser actions.
Then I should see my Message
@jbpros
Copy link

jbpros commented Aug 27, 2012

What about this:

#Higher level example
Feature: Automatically Update the Chat View
  Users should not have to refresh their browser to see the latest messages.

  Scenario: I send a message
    Given I am on the chatsite
    When I send a message #very high level, does not explain user's browser actions.
    Then I see my Message in the ChatView

@jbpros
Copy link

jbpros commented Aug 27, 2012

Oh and ChatView looks like a technical thingy. Couldn't you drop it?

How about this: Then I see my message

@fivetanley
Copy link
Author

Will change. Thanks a lot!

@jbpros
Copy link

jbpros commented Aug 27, 2012

Note that in your /^I see my message$/step definition, you can still assert several truths:

  • your message is displayed
  • your ID is displayed next to it

But these implementation details should probably not surface in the scenarios.

@fivetanley
Copy link
Author

Thanks much, it really helps out a new guy who doesn't fully understand this stuff yet.

Do you have any resources where I can learn good practices for these higher-level Cucumber tests?

@jbpros
Copy link

jbpros commented Aug 27, 2012

The most complete, though not free, one is The Cucumber Book. There is this interesting blogpost by Aslak too. The #cucumber IRC channel can be useful too (not super active, but patience can lead to results ;)). The mailing list is a good source of info too.

@jbpros
Copy link

jbpros commented Aug 27, 2012

That's a lot of toos.

@fivetanley
Copy link
Author

Awesome, thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment