Hi guys.

Lately I've been working on improving automated test coverage of core plugins. 
Work is still in progress but there are some results that I want to share.

The idea is to use Appium framework to automate core plugins manual tests in 
mobilespec app. I've implemented a new command for Medic. It starts an Appium 
server instance, looks for the tests, then runs the mobilespec app from the 
specified folder and runs the tests.

Appium supports only iOS and Android platforms so there are tests only for 
these two, but we can extend the coverage of other platforms using different ui 
testing frameworks.

The tests themselves are written for jasmine-node and are using "wd" module to 
connect to Appium server. They are currently located in plugin repos. Here's 
some links:

Test runner (medic):
https://github.com/apache/cordova-medic/pull/70

Battery Status tests:
https://github.com/apache/cordova-plugin-battery-status/pull/29

Camera tests:
https://github.com/apache/cordova-plugin-camera/pull/156

Contacts tests:
https://github.com/apache/cordova-plugin-contacts/pull/101

Device Motion tests:
https://github.com/apache/cordova-plugin-device-motion/pull/39

Tests can run on both real devices and emulators/simulators.
While developing the tests, I've been using Android emulator and device with 
API level 19 (Android 4.4, KitKat) and iOS device (iPad 2) with iOS 7.1 so the 
tests can fail on other devices/emulators. I'm going to add the support for 
other versions/devices as well as implement more Appium tests for other plugins 
in the nearest future.

To run the tests:
1. Clone cordova-medic repo
2. Clone tested plugins repos (appium tests are there, in appium-tests folder)
3. Create mobile spec app with tested plugins:
       node cordova-mobile-spec/createmobilespec/createmobilespec.js 
mobspec-android --android --plugins "cordova-plugin-battery-status 
cordova-plugin-camera cordova-plugin-contacts cordova-plugin-device-motion"
4. Build the mobilespec app:
       cd mobspec-android && cordova build
5. Start the emulator/connect the device
6. Run the tests using command:
node cordova-medic/medic/medic.js appium --app [mobilespec folder] --platform 
[platform] --device-name [device/emulator name] --platform-version [platform 
version] --plugins [list of plugins to test separated by space] [--device (only 
if running on a real device)] --udid [iOS real devices only, device UDID]
Every argument except --platform is optional. On iOS, --udid is mandatory if 
running on real device.

For example, android emulator:
node cordova-medic/medic/medic.js appium --app mobspec-android --platform 
android --device-name appium --platform-version 19 --plugins 
"cordova-plugin-device-motion"

Android device:
node cordova-medic/medic/medic.js appium --platform android --app 
mobspec-android --plugins "cordova-plugin-contacts" --device

iOS simulator: 
node cordova-medic/medic/medic.js appium --app mobspec-ios --platform ios 
--plugins "cordova-plugin-contacts"

iOS device:
node cordova-medic/medic/medic.js appium --app mobspec-ios --platform ios 
--device-name "iPad 2" --udid [UDID here] --plugins "cordova-plugin-camera 
cordova-plugin-contacts"

I hope we will be running these tests along with other medic tests that are now 
running on CI in future:
http://ci.cordova.io/

Please take a look and say what you think.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org

Reply via email to