1. Home
  2. Getting Started
  3. Writing Tests
    1. Included Steps
    2. Writing Your Own Steps
    3. View Selectors
    4. User Contributed Steps
    5. Testing on a Physical Device
    6. Testing Mac Apps
  4. More Information
    1. ruby gem documentation
    2. Presentations
    3. Screencasts
    4. FAQ
    5. Wire Protocol (Frankly)
  5. Get Involved
    1. Mailing Lists
    2. Contributing

Writing your own steps

Defining your own step definitions is pretty straightforward. A good place to start is to look at the step definitions that come with Frank to get an idea of what a step definiton looks like.

The first thing to do when writing your own steps is to write a feature file which contains the step you want to create, and then run that feature in cucumber. Cucumber will complain that that step doesn’t exist, but in doing so it will also output the boilerplate step definition code you need to get started defining that step yourself. Copy and paste that boilerplate into a new .rb file inside features/step_definitions/.

Now all you need to do is fill out that step definition block with the frank-cucumber commands you need to make that step a reality. Most of your step definition code is going to consist of calls to frank helper methods. This helper methods will do the heavy lifting for you of requesting certain automation actions to be carried out on your app or of checking that the state of your app meets your expectations. The helper methods are documented here.

For more guidance on this topic, take a look at this article. The second half of that article give some more detailed examples of how to write your own step definitions.