0
votes

I'm building Mobile apps test automation using Java, Cucumber-JVM, Appium.

For various scenarios, in order to make scenario verbose, we have added following line at the start of scenario/scenario outline / background of bdd feature files. for example:

 Given user with ios device "iPhone SE Simulator"
 And I select a book product
 And I select layout type "Square"

.. Another example

 Given user with ios device "iPhone 7"
  And I select a book product
  And I select layout type "Square"

.. Another example

 Given user with ios device "iPhone 6"
  And I select a book product
  And I select layout type "Tav"

Now, we have got many devices, so what will be the best way to reuse the step. I would like to avoid using Scenario Outline & parameterize on type?

Also, we're okay for slight repetition/duplication of feature files, if it helps to easily build test suite.

Kindly suggest

Thanks

2
Instead of using the device parameter from story line, you consider passing it with before hook or test parameter. So that same scenario can be repeated for multiple devices. - Murthi
pass the devcie from command line like -Ddevice="iPhone 7", and get the device argument value in beforeAll() hook, - yong
We would like to keep the story self-explanatory i.e. 1st line of the story should declare which mobile device its going to execute against. Also lot of underlying code has been built around this way of passing Mobile-type as a parameter in the BDD. Kindly suggest in this case./ Thanks - user2451016

2 Answers

1
votes

If you are using QAF you can simply define and use property

property file:

device.name=<your device name>

BDD

Given user with ios device "${device.name}"

Further more qaf supports different way to set properties as well as strong resource management for different environments.

0
votes

1) specify the device from command line:

-Ddevice="iPhone 6"

2) capture the device from command line in before All hook

class CLIParams {
  private static String device;
  public static void setDevice();
  public static String getDevice();
}

class Hook {
  @BeforeAll
  public beforeAll() {
    CLIParams.setDevice(System.getProperty("device", "iPhone 7"));
  }
}

3) step in feature file

Given user with mobile device "iPhone SE Simulator"
Given user with mobile device "iPhone 6"
Given user with mobile device "Google Neux"

4) step definition of the first line

Given("^user with mobile device \"(.?)\"$", (device)->{
  // ignore the deivce from the step description
  // instead to use the device from command line
  CLIParams.getDevice();
})

5) how to pass jvm args in eclipse eclipse run configuration

For other IDE, Intellij/NetBean should also has similar place to specify jvm args, if you run by command line just append -Ddevice="iPhon 7" to command