|
|
5 years ago | |
|---|---|---|
| .. | ||
| src | 5 years ago | |
| testcases | 5 years ago | |
| .gitignore | 5 years ago | |
| Makefile | 5 years ago | |
| README.md | 5 years ago | |
| testsuite.py | 5 years ago | |
This is a regression test suite for the PubSubClient library.
There are two parts:
It is a work-in-progress and is subject to complete refactoring as the whim takes me.
These are a set of executables that can be run to test specific areas of functionality. They do not require a real Arduino to be attached, nor the use of the Arduino IDE.
The tests include a set of mock files to stub out the parts of the Arduino environment the library depends on.
Build the tests using the provided Makefile:
$ make
This will create a set of executables in ./bin/. Run each of these executables to test the corresponding functionality.
Note: the connect_spec and keepalive_spec tests involve testing keepalive timers so naturally take a few minutes to run through.
Note: INO Tool doesn't currently play nicely with Arduino 1.5. This has broken this test suite.
Without a suitable arduino plugged in, the test suite will only check the example sketches compile cleanly against the library.
With an arduino plugged in, each sketch that has a corresponding python test case is built, uploaded and then the tests run.
The test suite does not run an MQTT server - it is assumed to be running already.
$ python testsuite.py
A summary of activity is printed to the console. More comprehensive logs are written
to the logs directory.
For each sketch in the library's examples directory, e.g. mqtt_basic.ino, the suite looks for a matching test case
testcases/mqtt_basic.py.
The test case must follow these conventions:
unittest.TestCasesetUpClass and tearDownClass (TODO: make this optional)test_The suite will call the setUpClass method before uploading the sketch. This
allows any test setup to be performed before the sketch runs - such as connecting
a client and subscribing to topics.
The file testcases/settings.py is used to config the test environment.
server_ip - the IP address of the broker the client should connect to (the broker port is assumed to be 1883).arduino_ip - the IP address the arduino should use (when not testing DHCP).Before each sketch is compiled, these values are automatically substituted in. To do this, the suite looks for lines that start with the following:
byte server[] = {
byte ip[] = {
and replaces them with the appropriate values.