SEMA
SEMA

Reputation: 83

Running automated tests for specified platform (Android or iOS). Only one platform per launch. How to specify which platform must be run by Maven?

Java, Maven, Appium, Cucumber

Project structure - packages:

Test cases are located in the package features - used Cucumber.

Tests run:

Now features (test cases on Cucumber) used the tag @ios-simulator. By this tag Cucumber finds the class with @Before(value="@ios-simulator") - run tests only for iOS. If you change all tags in the features to @android this will run tests under Android.

Problem: choose a platform for tests run -> change all tags in all test cases in the feature - an uncomfortable and routinely.

Goal: platform name must be stored in one place, for example in the pom.xml file. Cucumber or something else take this value and runs tests for selected platform (by choosing appropriate package). Or by command: mvn test -Dandroid - if maven is used.

Cucumber is response for tests runing. But how to choose the platform more comfortable - I do not know. Dynamically generate tags in features (take platform-name-value from the pom.xml file) doesn't work.

How to do this task by Maven or by Cucumber? Any ideas

Upvotes: 1

Views: 1206

Answers (1)

plosco
plosco

Reputation: 901

I would recommend adding something in your test setup like this

device = System.getProperty("device");

This should let you specify where you would want to run you tests via "iPhone Simulator" or "Android".

From the command line you would do something like

mvn -Ddevice="Android" test

Now you know what type of device you want to run on and you can set the platform you are testing. From there your tests should probably have some sort of global way of selecting or interacting with elements and can determine which version to use.

If your app truly is a hybrid app this should be fine otherwise I would keep seperate tests in the packages for the platforms.

I'm using junit and checking the package name of the test to automatically do other configurations.

if (this.getClass().getPackage().toString().contains("ios")) {
    platform = iOS;
}

Upvotes: 1

Related Questions