bshambaugh / BlinkyProject

4 stars 0 forks source link

Unit and Integration Testing for ESPx and Node.js for WebSockets #15

Open bshambaugh opened 1 year ago

bshambaugh commented 1 year ago

ESPx: https://gist.github.com/bshambaugh/384f5ba141c2acb16f8b37cb1e481149

Also try Ardunio CI, because there are issues getting Arduino code to test on the development machine otherwise. https://www.youtube.com/watch?v=vaS4AU_PXQo https://github.com/Arduino-CI/arduino_ci announcement on forum: https://forum.arduino.cc/t/running-automated-unit-tests-on-an-arduino-library-using-travis-ci/512703/1

This tutorial from AdaFruit will also help with automated CI for embedded code with Travis CI and GitHub: https://learn.adafruit.com/the-well-automated-arduino-library?view=all

This post helps with Integration with Gitlab and Arduino CI and bash scipts: https://codeblog.dotsandbrackets.com/gitlab-ci-esp32-arduino/

Node.js: https://twitter.com/Brent_Shambaugh/status/1596270357631336448?s=20&t=YsuO6o2I2TP7quVKswI92g --> I think to test all of the websocket functions in https://github.com/bshambaugh/key-did-provider-p256Test-remote I need to write integration tests: https://thomason-isaiah.medium.com/writing-integration-tests-for-websocket-servers-using-jest-and-ws-8e5c61726b2a --> https://github.com/ITenthusiasm/testing-websockets

bshambaugh commented 1 year ago

Alternatively you could try to refactor your code to use Rust: https://www.youtube.com/watch?v=0PPPdqoDBQs (Embedded Rust on ESP32 - Juraj Michálek - Rust Linz November 2022)

https://github.com/esp-rs

I was unable to find any tests in their repositories and not all libraries. such as websockets, are supported.

but here is how to write tests in Rust: https://doc.rust-lang.org/book/ch11-01-writing-tests.html

Alternatively, try JavaScript? https://www.moddable.com/ They actually do have tests: https://github.com/Moddable-OpenSource/moddable/blob/public/tests/modules/crypt/ecdsa/testvectors.js

https://github.com/Moddable-OpenSource/iot-product-dev-book/blob/master/ch3-network/websocket-client/example.js JavaScript is compiled down to C. Can I trust what I get?

bshambaugh commented 1 year ago

This is bad. Arduino-CI is built around the Ardunio IDE.

Arduino-CI is built around the Arduino IDE, not platform.io. I liked Platform.io because I could break up the files in the IDE rather than rely on a single *.ino file.

There is pio ci, but is thought of as a hot key, not as a way to run tests? https://docs.platformio.org/en/latest/core/userguide/cmd_ci.html

https://learn.sparkfun.com/tutorials/efficient-arduino-programming-with-arduino-cli-and-visual-studio-code/introduction-to-the-arduino-cli

https://forum.arduino.cc/t/does-platformio-offer-anything-more-than-arduino-cli-for-arduinos/928080

bshambaugh commented 1 year ago

https://github.com/espressif/esp-idf/tree/master/examples

https://docs.espressif.com/projects/esptool/en/latest/esp32/index.html

esp-idf --> https://www.reddit.com/r/esp32/comments/igenuf/using_arduino_libraries_with_espidf/