To run unittests a Test enviroment is needed.
- Fhem installation in /opt/fhem
- Experience in perl
- Knowledge of Test::More
You should not run the UnitTests on a productive used fhem installation.
-
install required test modules via
cpan Test::Device::SerialPort
cpan Mock::Sub
andcpan Test::More
On Systems with low memory, use cpanm for installing the packages. -
You can use make for running the tests. There is a makefile which will prepare your fhem installation for running the tests.
- stop any running fhem instance
- copy the module into the fhem directory /opt/fhem/FHEM
- copy a minimal config file for fhem fhem_ut.cfg and start fhem with this configfile.
- run the tests in the tests directory. They must be named -definition.txt
- cleans up logfiles
- stop fhem
Now you can start defining a unittest
cd /opt/fhem
perl fhem.pl fhem.cfg
You can run tests from the commandline. Make will do this for you automatic
Currently test-runner searches logfiles in /opt/fhem. So you can install your test instance of fhem into a separate directoy but you must link the logfile to /opt/fhem
Unit Testfiles are searched in the directory test.
If you call test-runer.sh my_test_1
then this will try to load a file test/my_test_1-definition.