Test ESP WebServer by Python scripts
With this library you can:
-
build firmware using Platformio
-
upload firmware using Platformio
-
connect to ESP8266/ESP32 Active Point
-
execute HTTP requests
-
compare web page content with templates
limitation: Only MacOS Wi-Fi adapter support. Please open an issues with your Wi-Fi adapter info.
Quick start
- install requirements by
pip install -r requirements.txt - call
$ pytest --noupload
Using
- create test_*.py files with your tests
- run
pyteswith options
pytest arguments
for compile firmware
- --lib - path to library you want to use
- --dir - path to folder with firmware source files
- --conf - path to platformio.ini file. if None use default
- --port - upload port
- --noupload - skip compiling and uploading firmware
for test chip
- --ssid - chip SSID name
- --channel - chip Wi-Fi channel
Example
We have:
/Documents/WiFiManager
/Documents/MyProject/src/main.cpp
/Documents/MyProject/platformio.ini
/Documents/ESPWebServerTest/test_my_project.py
Call:
pytest --lib=/Documents/WiFiManager --dir=/Documents/YourProject --port=/dev/cu.SLAB_USBtoUART
- move /Documents/MyProject to /Documents/ESPWebServerTest/sandbox
- move /Documents/WiFiManager to /Documents/ESPWebServerTest/sandbox/lib
- platformio run --target upload --upload-port /dev/cu.SLAB_USBtoUART
- call all test_ functions in test_my_project.py
Profit!
WiFiManager example test
- open
examples/WiFiManagerTest/OnDemandConfigPortalfolder - build firmware and upload it:
$ pytest --build --lib=/Users/user/Documents/WiFiManager --dir=/Users/user/Documents/WiFiManager/examples/DEV/OnDemandConfigPortal --port=/dev/cu.SLAB_USBtoUART - run tests:
$ pytest --ssid WM_ConnectAP --channel=8 --port=/dev/cu.SLAB_USBtoUART - see
logsfolder if errors