Sometimes it is useful to selectively run tests from a suite of mgunit tests. For example, in the GPULib unit test suite, certain tests required hardware capable of performing them, e.g., double precision computations, streaming, etc. There is a
SKIP keyword to
ASSERT to handle these situations. For example, a GPULib unit test requiring double precision hardware might do something like:
assert, gpuDoubleCapable(), 'CUDA device not double capable', /skip
This would skip the test, so the test would not count as either passed or failed. Here,
gpuDoubleCapable can perform a check to determine whether the hardware is double capable.
But this requires some type of global setting to be checked. It would be useful to be able pass arguments to
mgunit when starting the tests that could be checked during a test. I’ve added this feature to the master branch of mgunit.
To use this, define a super class for your tests that inherits from
MGutTestCase which accepts a keyword for your property, say
MY_PROPERTY, in its
::init method. Store that value in some manner, probably as an instance variable of your object, so that you can check it in your test. Then call
mgunit like this:
mgunit, 'my_tests_uts', MY_PROPERTY=1
This provides a convenient way to run your tests in various modes, skip certain tests, or pass other information to your tests.
This feature is only available in the master branch of mgunit right now, but should be in the next release.