How to unit test a cordova plugin using Junit?

北战南征 提交于 2019-12-08 19:10:32

You were right in your research that the current tests for the Cordova Core plugins are all using cordova-plugin-test-framework to implement tests that are run on the device with e.g. cordova-paramedic or cordova-mobile-spec (see the CI configuration in the GitHub repositories on how to trigger a build with cordova-paramedic for example).

The only Cordova projects where "normal" unit tests, written in Java for Android and Obj-C for iOS, are used are the platforms. For Android for example this folder exists: https://github.com/apache/cordova-android/tree/master/test These tests can be run via run_java_unit_tests.js, which is also available via npm as npm run java-unit-tests.

I am pretty sure the same concept could be applied to plugin tests.
(Please let me know if you try and this actually works!)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!