Antonio Terceiro antonio.terceiro@linaro.org writes:
Hello,
I was working on lava-dispatcher today, and I found out that is has (few) unit tests under lava_dispatchers/tests/, and I was wondering if is there a pattern/guideline/etc on how unit tests are used acrosss the lava components.
No :(
We are embarrassingly terrible at unit testing our code. If you starting can kick us into being a bit better, that would be awesome!
In special:
- How are we supposed to run the unit tests? I found a .testr.conf file
in lava-dispatcher, what gave me some hints, so I started doing
$ python -m subunit.run lava_dispatcher.tests.test_suite
The output of that was too verbose for my taste, so I ended up using
$ python -m unittest lava_dispatcher.tests.test_suite
which provides a cleaner output.
The presence of .testr.conf means that you can run tests by running "testr init" (once) and then "testr run" (after installing the testrepository package).
- I had problems running these tests within the system (a VM) where I
had lava installed, after activating the virtualenv-like environment with `. /src/lava/instances/$inst/bin/activate`. The commands above were always running the code that was installed in the lava instance instead of the code in the current directory. I guess that is related to the fact that I did not inject that directory to be used by the instance, right?
That's because after activating an instance, 'python' runs an interpreter with a fixed sys.path (I'm not sure that even $PYTHONPATH is honoured). This is both a good and bad thing... probably bad in this case.
This made me end up running the tests on my main system, where there was nothing installed - only the lava-dispatcher sources + the basic Python stuff.
As I think I said on IRC, I don't tend to do lava-dispatcher development inside an instance -- it doesn't depend on any of the other bits.
Cheers, mwh