androidcucumbercalabashcalabash-android

How to create a custom calabash step to run a command?


I am using calabash-android to test my app. I want to create a custom step which executes an adb command.

This is what I tried:

I created the following custom step which takes no arguments (I created it under step_definitions/ folder):

Run adb command for our app do |cukes|
   system("adb devices")
end

In my_first.feature, I call above step like this:

Feature: My feature

  Scenario: My scenario
    Run adb command for our app

When I run the test with the command calabash-android run myApp.apk, I get an error message:

syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{' or '('
Run adb command for our app do |cukes|

Where am I wrong? How to create a simple step which takes no argument & just runs one adb command?


Solution

  • Several issues:

    This should work:

    features/my_first.feature

    Feature: My feature
    
      Scenario: My scenario
        When I run the adb command for our app
    

    step_definitions/my_first_steps.rb

    When /^I run the adb command for our app$/ do
      system("adb devices")
    end