don / cordova-plugin-ble-central

Bluetooth Low Energy (BLE) Central plugin for Apache Cordova (aka PhoneGap)
Apache License 2.0
941 stars 601 forks source link

Test app installation fails; no tests listed #962

Open mikerusso-tsi opened 1 year ago

mikerusso-tsi commented 1 year ago

The following instruction for installing the test app yields an error: cordova plugin add ../cordova-plugin-ble-central/tests == > Invalid Plugin! ../cordova-plugin-ble-central/tests needs a valid package.json True, the repo has no package.json in the tests subdirectory. As a result, there are no tests listed when running the app. Is there a repair or work-around? Thanks!

peitschie commented 1 year ago

Hi @mikerusso-tsi

That's not surprising, as I haven't really used that test suite for a very long time 😅 What's driving your desire to get this running again?

I can see ways to make it work again probably, but it would be good to understand what you're wanting to get out of it!

mikerusso-tsi commented 1 year ago

Hi Philip, Thanks for the quick reply! I have been using the plugin for sometime now but had to get my app’s Android API level upgraded in order to have it accepted by Google Play. That triggered a long process of upgrading the various portions of the build environment. I was unaware of the test app until now and thought it would be a great milestone to see it running within my new build environment. Was it the best practice to pull in the tests as if they were a plugin as well? Could they just be incorporated into the app code? I was also happy to see the issue 925 code used in this app to manage the Android permissions, as well as to see the instructions for using the plugin in a Capacitor app! Thanks, Mike

peitschie commented 1 year ago

Right... that makes sense!

In terms of testing the plugin, the easiest thing is to create a clean cordova app, add the plugin, and then put a single ble.scan() with an alert in the demo JS file. There's almost always BLE devices around, and this checks that the underlying BLE hardware is all connecting properly.

The test code here itself relies on a plugin that I'm not sure is well maintained, and I haven't had a chance yet to dig into further. Let me know though if the above doesn't meet your needs well enough however 🙂

Either way, I should either remove or fix the test app instructions so I need to take some action.

mikerusso-tsi commented 1 year ago

It seemed like there was a very comprehensive set of tests and they would serve well as QA for the plugin, so I would certainly encourage you to get them going again.

I was unsure about your suggestion for an alert in a demo file - alerts weren't showing up for me. Instead, I added the following in jasmineDone() in platform/ios/platform_www/cdvtests/jasmine-2.4.1/jasmine-html.js and ran it on an iPad, tapping the various test run buttons to start new scans: var bleDevice = 'NO BLE'; ble.scan([], 5, function(device) { bleDevice = JSON.stringify(device); alert.appendChild(createDom('span', {className: statusBarClassName}, ' BLE Device = ' + bleDevice, seedBar)); } /*, failure */ ); The scan results then show up in the status bar. Thanks again for you help! Please reply here if you get the tests working!

peitschie commented 1 year ago

It seemed like there was a very comprehensive set of tests and they would serve well as QA for the plugin, so I would certainly encourage you to get them going again.

This particular aspect is well covered by a much more extensive set of automated multi-platform end-to-end tests I run against a farm of local hardware 🙂. This is used in some medical-related software applications across both iOS and Android, so I have a very vested interest in keeping it long-term stable across a variety of Android platforms and devices especially.

Glad you were able to prove out the build tools to your satisfaction however.

mikerusso-tsi commented 1 year ago

This particular aspect is well covered by a much more extensive set of automated multi-platform end-to-end tests I run against a farm of local hardware I share your interest in its stability... Is the testing you mentioned part of this plugin (repo) or outside of it?

peitschie commented 1 year ago

@mikerusso-tsi currently outside of the repo, unfortunately.

Apart from a standalone test set leveraging webdriver.io, I have access to several applications with their own dedicated automation suites as part of my job which are also leveraged to help test out the edges of the plugin itself.