1

Java, Maven, Appium, Cucumber

Project structure - packages:

  • android
  • ios
  • features

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

Tests run:

  • build jar file
  • through Intellij IDEA

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

4

1 回答 1

1

我建议在你的测试设置中添加一些像这样的东西

device = System.getProperty("device");

这应该让您指定您希望通过“iPhone Simulator”或“Android”运行测试的位置。

从命令行你会做类似的事情

mvn -Ddevice="Android" test

现在您知道要在什么类型的设备上运行,并且可以设置您正在测试的平台。从那里您的测试可能应该有某种选择或与元素交互的全局方式,并且可以确定要使用的版本。

如果您的应用程序确实是一个混合应用程序,这应该没问题,否则我会在平台的包中保留单独的测试。

我正在使用 junit 并检查测试的包名称以自动执行其他配置。

if (this.getClass().getPackage().toString().contains("ios")) {
    platform = iOS;
}
于 2014-04-10T16:06:35.377 回答