uniform unittest framework for GNU Octave and Matlab
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
# mUnittest
|
|
|
|
* uniform unittest framework for GNU Octave and Matlab
|
|
|
|
* `mUnittest('testscript')` will create `testscriptReport.xml` which is designed to work with Jenkins JUnit publish plugin. See
|
|
|
|
[Showcase with Jenkins](https://github.com/markuman/mUnittest/wiki/Showcase-with-Jenkins)
|
|
|
|
* `mUnittest()` is compatible with `runtests()` of Matlab >= R2014a.
|
|
|
|
|
|
|
|
## assert
|
|
|
|
|
|
|
|
The core of `mUnittest` is an overloaded `assert()` function. It works as the buildin `assert` up to the usage of the optional
|
|
|
|
messages.
|
|
|
|
|
|
|
|
### no messages
|
|
|
|
|
|
|
|
assert(cond)
|
|
|
|
|
|
|
|
`cond` _(condition)_ has to be `1` or `true`, otherwhise the `assert` will fail.
|
|
|
|
When no message is given, it gets the name of the testscript itself. E.g. given `testscript.m` contains
|
|
|
|
|
|
|
|
assert(0 == 1);
|
|
|
|
|
|
|
|
Running this mUnittest will looks like this
|
|
|
|
octave:1> mUnittest('testscript');
|
|
|
|
|
|
|
|
|
|
|
|
mUnittest: testscript
|
|
|
|
|
|
|
|
|
|
|
|
1 failed testscript_1
|
|
|
|
|
|
|
|
PASSED 0 OF 1
|
|
|
|
|
|
|
|
The message will be in this case `testscript_1` while the failure message of the `testscriptReport.xml` will be
|
|
|
|
|
|
|
|
<failure type="assert"> Test 1 failed </failure>
|
|
|
|
|
|
|
|
|
|
|
|
### messages
|
|
|
|
|
|
|
|
|
|
|
|
assert(cond, messageName, messageError)
|
|
|
|
|
|
|
|
You can name each `assert` test with the first messageName and a messageError. It will appears in Jenkins like that
|
|
|
|
|
|
|
|
assert(false, 'AnotherTest', 'I''m a possible reason why I failed')
|
|
|
|
|
|
|
|
... will look like this
|
|
|
|
|
|
|
|
octave:1> mUnittest('testscript');
|
|
|
|
|
|
|
|
|
|
|
|
mUnittest: testscript
|
|
|
|
|
|
|
|
|
|
|
|
1 failed AnotherTest
|
|
|
|
|
|
|
|
PASSED 0 OF 1
|
|
|
|
|
|
|
|
|
|
|
|
`testscript.AnotherTest` with failure tree `I'm a possible reason why I failed`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|