User Guide¶
- In a module’s root directory create a directory
tests
and place there a module configuration fileconfig.yaml
described in detail in section Configuration file. If you would like to use MTF without your ownconfig.yaml
. It is possible. It uses default minimal config. Then you have to setURL
envvar to set test subject, otherwise it causes traceback. It is usefull for example for module what does not provide any service (no ownstart/stop/status/etc
action defined.) or for testing with modulelint.
- Optionally write multiline Bash snippet tests directly in the
tests/config.yaml
file as described in section Multiline Bash snippet tests.
- Check the list of Environment variables.
- Write your tests, for example see sanity tests and various tests examples in
/usr/share/moduleframework/examples/testing-module/
. All tests methods are listed in section API Index and alphabetically in Index section.
In the directory
tests
create aMakefile
as below.Mind to keep the
mtf-generator
line only if there are multiline Bash snippet tests in thetests/config.yaml
file. Themtf-generator
command will convert those multiline Bash snippet tests from thetests/config.yaml
file into Python tests and stores them in thetests/generated.py
file, which will be processed further by avocado.
MODULE_LINT=/usr/share/moduleframework/tests/generic/*.py TESTS=*.py CMD=avocado run $(MODULE_LINT) $(TESTS) # all: mtf-generator $(CMD)
- In a module’s root directory create a
Makefile
, which contains a secton test. For example:
.PHONY: build run default IMAGE_NAME = debugging-tools MODULEMDURL=file://debugging-tools.yaml all: run default: run build: docker build --tag=$(IMAGE_NAME) . run: build docker run -it --name $(IMAGE_NAME) --privileged --ipc=host --net=host --pid=host -e HOST=/host -e NAME=$(IMAGE_NAME) -e IMAGE=$(IMAGE_NAME) -v /run:/run -v /var/log:/var/log -v /etc/machine-id:/etc/machine-id -v /etc/localtime:/etc/localtime -v /:/host $(IMAGE_NAME) test: build cd tests; MODULE=docker MODULEMD=$(MODULEMDURL) URL="docker=$(IMAGE_NAME)" make all cd tests; MODULE=nspawn MODULEMD=$(MODULEMDURL) make all cd tests; MODULE=openshift OPENSHIFT_IP="127.0.0.1" OPENSHIFT_USER="developer" OPENSHIFT_PASSWORD="developer" make all
- Prepare the environment to run tests in.
- Execute tests from the module root directory by running
#run tests from a module root directory $ make testor from the
tests
directory by running#run Python tests from the tests/ directory $ sudo MODULE=docker mtf ./*.pyor
#run Bash tests from the tests/ directory $ sudo MODULE=docker mtf ./*.sh
- Clean up the environment after test execution.
Contents:
See also
- API Index
- API Index
- webchat.freenode.net
- Questions? Help? Ideas? Stop by the #fedora-modularity chat channel on freenode IRC.