Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
228 views
in Technique[技术] by (71.8m points)

testng - Distributed native test execution over android devices

I need to execute a test suite in distributed mode over two android devices . i'm using appium and testng .Any one of you'll able to do so ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here you have a pretty good setup to use in your project: AppiumTestDistribution

E.g., you build with Maven, then add dependencies to your project:

<dependency>
  <groupId>com.github.saikrishna321</groupId>
  <artifactId>AppiumTestDistribution</artifactId>
<version>09c4398</version>
</dependency>

<repositories>
  <repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
  </repository>
</repositories>

And then you can run your tests like:

@Test
public void testApp() throws Exception {
    ParallelThread parallelThread = new ParallelThread();
    List<String> tests = new ArrayList<>();
    tests.add("HomePageTest2");
    tests.add("HomePageTest3");
    parallelThread.runner("com.test.site",tests);
}

Create config.properties file under your test directory, which should have below properties

RUNNER=distribute

## For appium 1.6.X users (If appium installed using npm)
APPIUM_JS_PATH=/usr/local/lib/node_modules/appium/build/lib/main.js

## For Windows users 
APPIUM_JS_PATH=C:/Users//AppData/Roaming/npm/node_modules/appium/build/lib/main.js
BROWSER_TYPE=chrome
APP_TYPE=NA
BUNDLE_ID=
FRAMEWORK=testng/cucumber
LISTENERS=listerner2,listerner2 (user can add custom listeners here, comma separated)
MAX_RETRY_COUNT=2 (Provide any retry count on failures, this is applied to all tests globally)

## Default path to capability json is root/caps/, if the location of the android.json & iOS.json is changed make sure you mention as below 
IOS_CAPS=relative/absolute
ANDROID_CAPS=relative/absolute 

## To run test on parallel simulators
DEVICE_PLATFORM=simulator

And run tests from command line:

Platform="android/ios/both" mvn clean -Dtest=Runner test

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...