Robot Framework Library for creating and interacting with devices using various adapters such as ssh, docker and local devices using the same interface.
-
Install via pip
pip install robotframework-devicelibrary[all] git+https://github.com/reubenmiller/robotframework-devicelibrary.git@0.24.4
Or add it to your
requirements.txt
filerobotframework-devicelibrary[all] @ git+https://github.com/reubenmiller/robotframework-devicelibrary.git@0.24.4
Then install it via
pip install -r requirements.txt
-
Create a
.env
file with the following environment variables (which will be the secrets)# SSH config (which device should be tested when using ssh) SSH_CONFIG_HOSTNAME= SSH_CONFIG_USERNAME= SSH_CONFIG_PASSWORD=
-
Create a common resource which contains your settings
tests/common.resource
${DEVICE_ADAPTER} docker &{SSH_CONFIG} hostname=%{SSH_CONFIG_HOSTNAME= } username=%{SSH_CONFIG_USERNAME= } password=%{SSH_CONFIG_PASSWORD= } &{DOCKER_CONFIG} image=%{DOCKER_CONFIG_IMAGE=debian-systemd}
Note
The common resource references the secrets stored in the .env file so secrets can be kept out of the repository.
-
Create a Robot test
tests/Example.robot
*** Settings *** Resource common.resource Library DeviceLibrary adapter=ssh *** Test Cases *** Check command execution Setup Device Execute Command On Device ls -la /etc/ Process Should Be Running On Device ssh
-
Run the test
robot tests/Example.robot
Checkout the DeviceLibrary docs
You can generate the docs yourself using:
libdoc DeviceLibrary/DeviceLibrary.py show > docs/DeviceLibrary.rst
Or you can create the html docs using:
libdoc ./DeviceLibrary/DeviceLibrary.py docs/DeviceLibrary.html
Then open the docs/DeviceLibrary.html file in your local web browser.