Paramedic • noun provides advanced levels of care at the point of illness or injury, including out of hospital treatment, and diagnostic services
cordova-paramedic is a tool to automate execution of Cordova plugins tests (via cordova-plugin-test-framework).
You can use Paramedic to build and run a Cordova app with plugin tests, run these tests on local emulators, and report the results. It can be used on a local or Continuous Integration environment.
Cordova Paramedic is currently used to automatically run all plugin tests on CI.
(See this workshop instructions for some additional explanation.)
- Cordova Paramedic (Test Automation)
- Android
- Browser
- iOS
A full Paramedic run will:
-
Create and prepare the app
- Create a temporary Cordova project with
cordova create - Install various plugins with
cordova plugin add %local_path%(e.g.cordova plugin add ../cordova-plugin-inappbrowser):- the plugin to be tested (e.g.
../cordova-plugin-inappbrowser) - the tests of this plugin (e.g.
../cordova-plugin-inappbrowser/tests) cordova-plugin-test-framework(from npm)- local
paramedic-plugin
- the plugin to be tested (e.g.
- Update the app start page to the test page at
cdvtests/index.html(provided bycordova-plugin-test-frameworkand the plugin tests) - Add the platform to be tested with
cordova platform add ... - Confirm the requirements for that platform are met with
cordova requirements ... - Start a local socket server for communication between the app running on a device/emulator and paramedic
- Make the server address known to the app
- Create a temporary Cordova project with
-
Run the tests
-
Either run the main tests locally...
- Skip main tests if option set (platform != android)
- Start a file transfer server if required
- Get the test command for the platform
- Manipulate permissions on iOS
- Run the app (open in browser, start emulator, run on device or emulator) and start the tests by doing so
- Skip main tests if option set
- Skip tests if action = run|emulate (= build)
- Wait for device to connect to server before timeout
- Wait for the tests results
- Time out if "connection takes to long" TODO (failure)
- Receive and handle "tests are done" (success) and "device disconnected" (failure) events
- (browser) Close the running browser
-
-
Clean up
1. Handle timeouts of test execution above 2. Collect Device Logs 3. Uninstall App 4. Kill Emulator Process 5. Clean up Project
Using npmjs registry version:
npm install -g cordova-paramedicUsing GitHub version:
npm install -g github:apache/cordova-paramedicor
git clone https://github.com/apache/cordova-paramedicIf cloning from GitHub, you will need to run npm link inside the checkout repository.
Alternativly, replace all occurences of cordova-paramedic with the command:
cordova-paramedic/main.jsfor Linux or macOSnode cordova-paramedic/main.jsfor Windows
Paramedic parameters can be passed via command line arguments or separate configuration file:
By Command Line Arguments:
cordova-paramedic --platform PLATFORM --plugin PATH <other parameters>By Configuration File:
cordova-paramedic --config ./sample-config/.paramedic.config.jsSome common use cases of Paramedic:
Run without any parameters to get a list of supported parameters:
cordova-paramedicTest your current plugin on an Android emulator:
cordova-paramedic --platform android --plugin ./Test your current plugin on a specific Android device (ID via adb devices -l):
cordova-paramedic --platform android --plugin ./ --target 02e7f7e9215da7f8Specifies target Cordova platform (could refer to local directory, npm or git)
cordova-paramedic --platform ios --plugin cordova-plugin-inappbrowser
cordova-paramedic --platform [email protected] --plugin cordova-plugin-inappbrowser
cordova-paramedic --platform ios@../cordova-ios --plugin cordova-plugin-inappbrowser
cordova-paramedic --platform ios@https://github.com/apache/cordova-ios.git#4.1.0 --plugin cordova-plugin-inappbrowserSpecifies test plugin, you may specify multiple --plugin flags and they will all be installed and tested together. You can refer to absolute path, npm registry or git repo.
If the plugin requires variables to install, you can specify them along with its name.
cordova-paramedic --platform ios --plugin cordova-plugin-inappbrowser
cordova-paramedic --platform ios --plugin 'azure-mobile-engagement-cordova --variable AZME_IOS_CONNECTION_STRING=Endpoint=0;AppId=0;SdkKey=0'
cordova-paramedic --platform ios --plugin https://github.com/apache/cordova-plugin-inappbrowser
// several plugins
cordova-paramedic --platform ios --plugin cordova-plugin-inappbrowser --plugin cordova-plugin-contactsVerbose mode. Display more information output
cordova-paramedic --platform ios --plugin cordova-plugin-inappbrowser --verboseA path to Cordova CLI. Useful when you're testing against locally installed Cordova version.
cordova-paramedic --platform android --plugin cordova-plugin-device --cli ./cordova-cli/bin/cordovaJust builds the project, without running the tests.
cordova-paramedic --platform ios --plugin cordova-plugin-inappbrowser --justbuildFor Android: The device ID (from adb devices -l) of a device the tests should be run on.
cordova-paramedic --platform android --plugin cordova-plugin-contacts --target 02e7f7e9215da7f8For iOS: A string that is used to pick the device (from the cordova run --list --emulator output) the tests should be run on.
cordova-paramedic --platform ios --plugin cordova-plugin-contacts --target "iPhone-8"Port to use for posting results from emulator back to paramedic server (default is from 8008). You can also specify a range using --startport and endport and paramedic will select the first available.
cordova-paramedic --platform ios --plugin cordova-plugin-inappbrowser --port 8010
cordova-paramedic --platform ios --plugin cordova-plugin-inappbrowser --startport 8000 endport 8020Time in millisecs to wait for tests to pass|fail (defaults to 10 minutes).
cordova-paramedic --platform ios --plugin cordova-plugin-inappbrowser --timeout 30000Directory location to store test results in junit format and the device logs
cordova-paramedic --platform ios --plugin cordova-plugin-inappbrowser --outputDir /Users/sampleuser/testresultsFlag to indicate the sample application folder must be deleted.
cordova-paramedic --platform ios --plugin cordova-plugin-inappbrowser --cleanUpAfterRuniOS only parameter. The path to the sample TCC DB file, with permissions, to be copied to the simulator.
cordova-paramedic --platform ios --plugin cordova-plugin-contacts --tccDbPath tcc.dbAdd additional parameters to the cordova build and cordova run commands.
cordova-paramedic --platform ios --plugin cordova-plugin-contacts --args=--buildFlag='-UseModernBuildSystem=0'Configuration file is used when no parameters are passed to cordova-paramedic call or explicitly specified via --config parameter:
cordova-paramedic <- paramedic will attempt to find .paramedic.config.js in working directory
cordova-paramedic --config ./sample-config/.paramedic.config.jsExample configuration file is showed below.
module.exports = {
"plugins": [
"https://github.com/apache/cordova-plugin-inappbrowser"
],
"platform": "android",
"action": "run",
"args": ""
}More configuration file examples could be found in sample-config folder.
You can also use cordova-paramedic as a module directly:
var paramedic = require('cordova-paramedic');
paramedic.run(config);