Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where should I run the ios test? #95

Closed
nobody4t opened this issue Jan 25, 2019 · 15 comments
Closed

Where should I run the ios test? #95

nobody4t opened this issue Jan 25, 2019 · 15 comments

Comments

@nobody4t
Copy link

nobody4t commented Jan 25, 2019

I am new to Cordova and I want to know more about the test process.
I found this https://kerrishotts.github.io/pgday/workshops/2017/campp/testing.html#cordova-paramedic, in which some steps are provided to test a plugin.

I am still confused that where should I start the test. In the tests dir or in the root dir of plugin ? Or somewhere else? I assume that I will have to run the test in tests dir. But it failed with Failed to install plugin : tests. So I am confused now.

Please help me with this. Thanks.

@janpio
Copy link
Member

janpio commented Jan 25, 2019

What are you trying to do - develop a plugin?

Paramedic is an extra thing to run the plugin tests. One way to use it is outside the context of the plugin. See the Travis configuration of the camera plugin for example:

node /tmp/paramedic/main.js --config pr/$PLATFORM --plugin $(pwd) --shouldUseSauce
--buildName travis-plugin-camera-$TRAVIS_JOB_NUMBER;

https://github.com/apache/cordova-plugin-camera/blob/24c8b6c43dd986c3197017823b750d1368c9ff9b/.travis.yml#L93-L94

This executes the paramedic script and gives it --plugin FOLDER_OF_THE_CAMERA_PLUGIN_CHECKOUT as a parameter.

The other way is to install Paramedic globally, so it is available as cordova-paramedic and then use a command like this in the root of your plugin: cordova-paramedic --platform android --plugin ./ This will test the current plugin on Android.

If this doesn't work and you get error messages, let me know and post the complete output you are getting - I am sure I can help you debug this.

@nobody4t
Copy link
Author

nobody4t commented Jan 25, 2019

@janpio thanks for reply so soon.
I try to test the plugin which is for iOS. I thought this plugin should be part of some application. So it should be test as part of app. With this command, can I test it independently?

I tried the command. I got the error as below. Did I miss anything?

output: Building for iPhone X Simulator
Building project: /private/var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-54177BnigJvlSRdS5/platforms/ios/HelloCordova.xcworkspace
	Configuration: Debug
	Platform: emulator
Build settings from command line:
    CONFIGURATION_BUILD_DIR = /private/var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-54177BnigJvlSRdS5/platforms/ios/build/emulator
    SDKROOT = iphonesimulator12.1
    SHARED_PRECOMPS_DIR = /private/var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-54177BnigJvlSRdS5/platforms/ios/build/sharedpch

Build settings from configuration file '/private/var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-54177BnigJvlSRdS5/platforms/ios/cordova/build-debug.xcconfig':
    CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES
    CODE_SIGN_ENTITLEMENTS = $(PROJECT_DIR)/$(PROJECT_NAME)/Entitlements-$(CONFIGURATION).plist
    CODE_SIGN_IDENTITY = iPhone Developer
    ENABLE_BITCODE = NO
    GCC_PREPROCESSOR_DEFINITIONS = DEBUG=1
    HEADER_SEARCH_PATHS = "$(TARGET_BUILD_DIR)/usr/local/lib/include" "$(OBJROOT)/UninstalledProducts/include" "$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include" "$(BUILT_PRODUCTS_DIR)"
    OTHER_LDFLAGS = -ObjC
    SWIFT_OBJC_BRIDGING_HEADER = $(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h

No target specified for emulator. Deploying to iPhone-5, 10.2 simulator
/private/var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-54177BnigJvlSRdS5/platforms/ios/build/emulator/HelloCordova.app/Info.plist file not found.

@janpio
Copy link
Member

janpio commented Jan 25, 2019

Paramedic runs the tests outside of your application, it builds its own one during the testing setup - and then runs the tests that are defined for the plugin.

What command did you execute to get the result above? (Please also try to include the complete output you get in the command line - often there are important info bits for contet)

A start would be to check out e.g. the camera plugin and execute your test command there - and see if this works. If it does, then the problem might be with your current plugin.

@nobody4t
Copy link
Author

nobody4t commented Jan 25, 2019

I just run cordova-paramedic cordova-paramedic --platform ios --plugin cordova-plugin-device
This plugin is from https://github.com/apache/cordova-plugin-device.


cordova-paramedic: creating temp project at /var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-59560aLfmeJOCwveo
cordova-paramedic: installing cordova-plugin-device
cordova-paramedic: installing cordova-plugin-device/tests
cordova-paramedic: installing plugin-test-framework
cordova-paramedic: starting local medic server ios
(node:59560) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
cordova-paramedic: writing medic log url to project
cordova-paramedic: setting app start page to test page
cordova-paramedic: adding platform
Error: cordova emulate return error code 1
output: Building for iPhone X Simulator
Building project: /private/var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-59560aLfmeJOCwveo/platforms/ios/HelloCordova.xcworkspace
	Configuration: Debug
	Platform: emulator
Build settings from command line:
    CONFIGURATION_BUILD_DIR = /private/var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-59560aLfmeJOCwveo/platforms/ios/build/emulator
    SDKROOT = iphonesimulator12.1
    SHARED_PRECOMPS_DIR = /private/var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-59560aLfmeJOCwveo/platforms/ios/build/sharedpch

Build settings from configuration file '/private/var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-59560aLfmeJOCwveo/platforms/ios/cordova/build-debug.xcconfig':
    CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES
    CODE_SIGN_ENTITLEMENTS = $(PROJECT_DIR)/$(PROJECT_NAME)/Entitlements-$(CONFIGURATION).plist
    CODE_SIGN_IDENTITY = iPhone Developer
    ENABLE_BITCODE = NO
    GCC_PREPROCESSOR_DEFINITIONS = DEBUG=1
    HEADER_SEARCH_PATHS = "$(TARGET_BUILD_DIR)/usr/local/lib/include" "$(OBJROOT)/UninstalledProducts/include" "$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include" "$(BUILT_PRODUCTS_DIR)"
    OTHER_LDFLAGS = -ObjC
    SWIFT_OBJC_BRIDGING_HEADER = $(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h

No target specified for emulator. Deploying to iPhone-5, 10.2 simulator
/private/var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-59560aLfmeJOCwveo/platforms/ios/build/emulator/HelloCordova.app/Info.plist file not found.

result code is : 1```

@janpio
Copy link
Member

janpio commented Jan 25, 2019

Oh, wait a minute - how did you install paramedic? We haven't released the lastest fixes, that is why your output doesn't match mine at all. Best use the second method mentioned here: https://github.com/apache/cordova-paramedic#installation

@nobody4t
Copy link
Author

I installed it with npm install -g cordova-parametic
Then I install it with second cmd, git clone it and then npm link. It is successful.
But I got the error below. The plugin is cordova-plugin-device.

cordova-paramedic: Will use the following cli: cordova
(node:78998) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
cordova-paramedic: creating temp project at /var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-78998F165NL1SQuMG
$ cordova create /var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-78998F165NL1SQuMG --no-telemetry --no-update-notifier
/private/var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-78998F165NL1SQuMG /Users/dong/repos/indy-ios/helloCordova/plugins
cordova-paramedic: installing plugins
cordova-paramedic: installing plugin /Users/dong/repos/indy-ios/helloCordova/plugins/cordova-plugin-device --no-telemetry --no-update-notifier
$ cordova plugin add /Users/dong/repos/indy-ios/helloCordova/plugins/cordova-plugin-device --no-telemetry --no-update-notifier
cordova-paramedic: installing plugin /var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-78998F165NL1SQuMG/plugins/cordova-plugin-device/tests --no-telemetry --no-update-notifier
$ cordova plugin add /var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-78998F165NL1SQuMG/plugins/cordova-plugin-device/tests --no-telemetry --no-update-notifier
cordova-paramedic: versions of installed plugins: 
$ cordova plugins --no-telemetry --no-update-notifier
cordova-paramedic: installing plugin /Users/dong/repos/indy-ios/helloCordova/plugins/cordova-plugin-test-framework --no-telemetry --no-update-notifier
$ cordova plugin add /Users/dong/repos/indy-ios/helloCordova/plugins/cordova-plugin-test-framework --no-telemetry --no-update-notifier
Error: Failed to install plugin : /Users/dong/repos/indy-ios/helloCordova/plugins/cordova-plugin-test-framework --no-telemetry --no-update-notifier
Completed tests at 5:43:26 AM
Collecting logs for the devices.
It looks like there is no target to get logs from.
Uninstalling the app.
Error: Failed to install plugin : /Users/dong/repos/indy-ios/helloCordova/plugins/cordova-plugin-test-framework --no-telemetry --no-update-notifier
    at PluginsManager.installSinglePlugin (/Users/dong/repos/cordova-paramedic/lib/PluginsManager.js:87:15)
    at PluginsManager.installPlugins (/Users/dong/repos/cordova-paramedic/lib/PluginsManager.js:37:14)
    at ParamedicRunner.installPlugins (/Users/dong/repos/cordova-paramedic/lib/paramedic.js:180:25)
    at ParamedicRunner.prepareProjectToRunTests (/Users/dong/repos/cordova-paramedic/lib/paramedic.js:152:10)
    at /Users/dong/repos/cordova-paramedic/lib/paramedic.js:76:21
    at _fulfilled (/Users/dong/repos/cordova-paramedic/node_modules/q/q.js:854:54)
    at /Users/dong/repos/cordova-paramedic/node_modules/q/q.js:883:30
    at Promise.promise.promiseDispatch (/Users/dong/repos/cordova-paramedic/node_modules/q/q.js:816:13)
    at /Users/dong/repos/cordova-paramedic/node_modules/q/q.js:877:14
    at runSingle (/Users/dong/repos/cordova-paramedic/node_modules/q/q.js:137:13)```

@nobody4t
Copy link
Author

When I try the cordova-plugin-console plugin I got different error.

(node:79116) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
cordova-paramedic: creating temp project at /var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-791164SpwlDcLRgeh
$ cordova create /var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-791164SpwlDcLRgeh --no-telemetry --no-update-notifier
/private/var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-791164SpwlDcLRgeh /Users/dong/repos/indy-ios/helloCordova/plugins
cordova-paramedic: installing plugins
cordova-paramedic: installing plugin /Users/dong/repos/indy-ios/helloCordova/plugins/cordova-plugin-console --no-telemetry --no-update-notifier
$ cordova plugin add /Users/dong/repos/indy-ios/helloCordova/plugins/cordova-plugin-console --no-telemetry --no-update-notifier
cordova-paramedic: installing plugin /var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-791164SpwlDcLRgeh/plugins/cordova-plugin-console/tests --no-telemetry --no-update-notifier
$ cordova plugin add /var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-791164SpwlDcLRgeh/plugins/cordova-plugin-console/tests --no-telemetry --no-update-notifier
cordova-paramedic: versions of installed plugins: 
$ cordova plugins --no-telemetry --no-update-notifier
cordova-paramedic: installing plugin /Users/dong/repos/indy-ios/helloCordova/plugins/cordova-plugin-test-framework --no-telemetry --no-update-notifier
$ cordova plugin add /Users/dong/repos/indy-ios/helloCordova/plugins/cordova-plugin-test-framework --no-telemetry --no-update-notifier
cordova-paramedic: installing plugin /Users/dong/repos/cordova-paramedic/paramedic-plugin --no-telemetry --no-update-notifier
$ cordova plugin add /Users/dong/repos/cordova-paramedic/paramedic-plugin --no-telemetry --no-update-notifier
cordova-paramedic: installing plugin /Users/dong/repos/cordova-paramedic/ios-geolocation-permissions-plugin --no-telemetry --no-update-notifier
$ cordova plugin add /Users/dong/repos/cordova-paramedic/ios-geolocation-permissions-plugin --no-telemetry --no-update-notifier
cordova-paramedic: setting app start page to test page
cordova-paramedic: adding platform ios (with:  --no-telemetry --no-update-notifier)
$ cordova platform add ios --no-telemetry --no-update-notifier
cordova-paramedic: successfully finished adding platform ios
cordova-paramedic: checking requirements for platform ios
$ cordova requirements ios --no-telemetry --no-update-notifier
cordova-paramedic: successfully finished checking requirements for platform ios
local-server: scanning ports from 7008 to 7208
local-server: port 7143 is available
local-server: starting local medic server
cordova-paramedic: writing medic log url to project http://127.0.0.1:7143
Start running tests at 5:46:08 AM
cordova-paramedic: running tests locally
cordova-paramedic: Choosing Target for iOS
running:
    cordova run --list --emulator --no-telemetry --no-update-notifier | grep ^iPhone | tail -n1
$ cordova run --list --emulator --no-telemetry --no-update-notifier | grep ^iPhone | tail -n1
running:
    instruments -s devices | grep ^iPhone
$ instruments -s devices | grep ^iPhone
cordova-paramedic: Setting required permissions.
cordova-paramedic: running command cordova run ios --no-telemetry --no-update-notifier --target iPhone-5 --emulator
$ cordova run ios --no-telemetry --no-update-notifier --target iPhone-5 --emulator
Completed tests at 5:46:17 AM
Collecting logs for the devices.
Running Command: cat /Users/dong/Library/Logs/CoreSimulator/8C184888-7671-4184-BD12-5BC9C0DEDA7C/system.log
$ cat /Users/dong/Library/Logs/CoreSimulator/8C184888-7671-4184-BD12-5BC9C0DEDA7C/system.log
Error: Failed to run command: cat /Users/dong/Library/Logs/CoreSimulator/8C184888-7671-4184-BD12-5BC9C0DEDA7C/system.log
Error: Failure code: 1
Uninstalling the app.
cordova-paramedic: Running command: xcrun simctl uninstall 8C184888-7671-4184-BD12-5BC9C0DEDA7C uninstall io.cordova.hellocordova
$ xcrun simctl uninstall 8C184888-7671-4184-BD12-5BC9C0DEDA7C uninstall io.cordova.hellocordova
Error: Failed to uninstall the app
Error: Error code: 164
cordova-paramedic: App uninstall timed out!
local-server: killing local file transfer server if it's up...
Building for iPhone 5 Simulator
Building project: /private/var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-791164SpwlDcLRgeh/platforms/ios/HelloCordova.xcworkspace
	Configuration: Debug
	Platform: emulator
Build settings from command line:
    CONFIGURATION_BUILD_DIR = /private/var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-791164SpwlDcLRgeh/platforms/ios/build/emulator
    SDKROOT = iphonesimulator12.1
    SHARED_PRECOMPS_DIR = /private/var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-791164SpwlDcLRgeh/platforms/ios/build/sharedpch

Build settings from configuration file '/private/var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-791164SpwlDcLRgeh/platforms/ios/cordova/build-debug.xcconfig':
    CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES
    CODE_SIGN_ENTITLEMENTS = $(PROJECT_DIR)/$(PROJECT_NAME)/Entitlements-$(CONFIGURATION).plist
    CODE_SIGN_IDENTITY = iPhone Developer
    ENABLE_BITCODE = NO
    GCC_PREPROCESSOR_DEFINITIONS = DEBUG=1
    HEADER_SEARCH_PATHS = "$(TARGET_BUILD_DIR)/usr/local/lib/include" "$(OBJROOT)/UninstalledProducts/include" "$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include" "$(BUILT_PRODUCTS_DIR)"
    OTHER_LDFLAGS = -ObjC
    SWIFT_OBJC_BRIDGING_HEADER = $(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h

/private/var/folders/kw/clrlzzcd3sz8tvpxpgbv3rv00000gn/T/tmp-791164SpwlDcLRgeh/platforms/ios/build/emulator/HelloCordova.app/Info.plist file not found.

As I found from the file /Users/dong/Library/Logs/CoreSimulator/CoreSimulator.log. There are so many lines like below:
CoreSimulatorService[2522] <Error>: Error Domain=com.apple.CoreSimulator.SimError Code=162 "Incompatible device" UserInfo={NSLocalizedDescription=Incompatible device}

It seems that cordova-paramedic use the iPhone-5 as default. How can change it to 12.0. I did not think I install iPhone-5. So I think this may be the problem. We need to test at latest version. The 5 is too old.

@janpio
Copy link
Member

janpio commented Jan 25, 2019

Damn, you arr having a terrible experience here. Sorry about that.
We seem to be using much older Xcode versions, and then it still works. So you are currently doing the work we will have to do one day anyway...

I do not know if there is a parameter to overwrite the simulator being used.

I found this code regarding the simulator:

function getSimulatorsFolder() {
var simulatorsFolderPath = path.join(path.homedir(), 'Library', 'Developer', 'CoreSimulator', 'Devices');
return simulatorsFolderPath;
}
function getSimulatorModelId(cli, target) {
var findSimCommand;
if (target) {
findSimCommand = cli + ' run --list --emulator' + module.exports.PARAMEDIC_COMMON_CLI_ARGS + ' | grep ' + target + ' | tail -n1';
} else {
findSimCommand = cli + ' run --list --emulator' + module.exports.PARAMEDIC_COMMON_CLI_ARGS + ' | grep ^iPhone | tail -n1';
}
logger.info('running:');
logger.info(' ' + findSimCommand);
var findSimResult = exec(findSimCommand);
if (findSimResult.code > 0) {
logger.error('Failed to find simulator we deployed to');
return;
}
return findSimResult.output;
}
function getSimulatorId(findSimResult) {
var split = findSimResult.split(', ');
// Format of the output is "iPhone-6s-Plus, 9.1"
// Extract the device name and the version number
var device = split[0].replace(/-/g, ' ').trim();
var version = split[1].trim();
// Next, figure out the ID of the simulator we found
var instrCommand = 'instruments -s devices | grep ^iPhone';
logger.info('running:');
logger.info(' ' + instrCommand);
var instrResult = exec(instrCommand);
if (instrResult.code > 0) {
logger.error('Failed to get the list of simulators');
return;
}
// This matches <device> (<version>) [<simulator-id>]
var simIdRegex = /^([a-zA-Z\d ]+) \(([\d.]+)\) \[([a-zA-Z\d\-]*)\].*$/;
var simulatorIds = instrResult.output.split(/\n/)
.reduce(function (result, line) {
var simIdMatch = simIdRegex.exec(line);
if (simIdMatch && simIdMatch.length === 4 && simIdMatch[1] === device && simIdMatch[2] === version) {
result.push(encodeURIComponent(simIdMatch[3]));
}
return result;
}, []);
if (simulatorIds.length > 1) {
logger.warn('Multiple matching emulators found. Will use the first matching simulator');
}
return simulatorIds[0];
}
Also this comand is executed in you log: cordova run --list --emulator --no-telemetry --no-update-notifier | grep ^iPhone | tail -n1 What does it return? What about cordova run --list --emulator --no-telemetry --no-update-notifier | grep ^iPhone?

@nobody4t
Copy link
Author

This is the return value of first one cmd: iPhone-5, 10.2
And iPhone-5s, 12.1 iPhone-5s, 10.2 iPhone-6, 12.1 iPhone-6, 10.2 iPhone-6-Plus, 12.1 iPhone-6-Plus, 10.2 iPhone-6s, 12.1 iPhone-6s, 10.2 iPhone-6s-Plus, 12.1 iPhone-6s-Plus, 10.2 iPhone-7, 12.1 iPhone-7, 10.2 iPhone-7-Plus, 12.1 iPhone-7-Plus, 10.2 iPhone-8, 12.1 iPhone-8-Plus, 12.1 iPhone-SE, 12.1 iPhone-SE, 10.2 iPhone-X, 12.1 iPhone-5, 10.2

Ah it seems that iPhone-5 is installed. But My xcode version is 10.1. Does that matter?

@janpio
Copy link
Member

janpio commented Jan 25, 2019

No idea to be honest. It might, because of apache/cordova-ios#407 :(

@nobody4t
Copy link
Author

probably. I got this UseModernBuildSystem=0 times when I have xcode 10. What if I want to have a try with xcode 10 how can I enable it in cordova-paramedic? Is it easy to do that?

@janpio
Copy link
Member

janpio commented Jan 25, 2019

Find the code that produces this output:

cordova-paramedic: Setting required permissions.
cordova-paramedic: running command cordova run ios --no-telemetry --no-update-notifier --target iPhone-5 --emulator
$ cordova run ios --no-telemetry --no-update-notifier --target iPhone-5 --emulator

and add the bit to the run command (afaik that is where it should be added).

@nobody4t
Copy link
Author

OK. Thanks for the reply.
BTW, is there any other way to test the plugin? Some document will be fine.

@janpio
Copy link
Member

janpio commented Jan 25, 2019

Paramedic uses https://github.com/apache/cordova-plugin-test-framework to run those tests, you can also build an app with it manually.

The Cordova testing setup is not very well documented, I am currently fighting my way through all the repositories connected and try to write it down.

Let me just copy my current draft for the plugins part in here:


Plugins

Plugin tests are somewhat special, as they are set up in a different way. npm run tests just includes the syntax check, while the real tests are run by other means:

Native

https://github.com/apache/cordova-plugin-camera/tree/master/tests/ios
https://github.com/apache/cordova-plugin-splashscreen/tree/master/tests/ios
https://github.com/apache/cordova-plugin-wkwebview-engine/tree/master/tests/ios

Plugin tests with cordova-plugin-test-framework

The actual tests can be found as test.js in a /tests folder. The automated tests, exported as defineAutoTests, use the familiar jasmine syntax, while the manual tests can be any HTML elements - usually buttons that trigger a JS function, with a description of the expected result underneath - exported via defineManualTests.

Additionally, the /tests folder contains its own package.json and config.xml to create a "mini test plugin" to be used by cordova-plugin-test-framework to create a test interface (manual UI and jasmine test runner) that is viewable inside an app: Create a new app, add the plugin, add the "tests" sub-plugin and you can navigate to cdvtests/index.html in your app to view that test interface.

Appium Tests

A small number of plugins also implements End to End Tests with Appium. They live in /appium-tests.
TODO Native code is being execised vs. JS part with all the other test types

Paramedic: cordova-paramedic

To automate the creating of a test app and the test execution process cordova-paramedic can be be used:

  1. Install cordova-paramedic (npm install -g ... or clone + npm install)
  2. Run Paramedic for the current plugin:
    node /tmp/paramedic/main.js 
      --config pr/$PLATFORM 
      --plugin $(pwd) 
    
  3. App is built, setup; Tests are run and results reported
Sauce Labs

Paramedic can also run these tests on a remote service called Sauce Labs. They offer emulators and real devices of all kind to run testing on. Both normal plugin tests and Appium tests are executed on Sauce Labs on different operating systems and operating system versions.

Core Plugins

(Almost) All Core Plugins implement tests in the previously described ways. Some focus on automated tests, some on manual ones. The plugin tests are executed on CI by the already mentioned cordova-paramedic on Sauce Labs.


@nobody4t
Copy link
Author

@janpio Thanks very much for the doc. Really appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants