I would like to run MUnit tests inside TestSuite constructs from the command line or a notebook interface without loading the Workbench GUI. I tried


where suite.mt contains:


and each of the fileX.mt contain standard Test[...] constructs. However, this does not run the tests; I get the output that 0 tests were run. TestRun["file1.mt"] works. I cannot find documentation for TestRun, so maybe it does not support this, but in that case, how do I run testsuite files without loading the Workbench GUI?

Edit: Since MUnit v1.4 (which is distributed with Mathematica v10) TestRun function correctly handles path to test suite file.

  • 1
    $\begingroup$ The code for MUnit package, by the look of it, seems to be really well-written and self-documenting, so, if all else fails, you can read the source and see what is needed to get it to work. What I personally did in a similar situation was that I wrote my own package to load .mt files and have a fine-grained control over them, and also a custom UI to run them in the FrontEnd, and while it worked great for me, I don't want to encourage that approach - it is probably better to use what MUnit provides since there obviously was a lot of work and thought put into that already. $\endgroup$ – Leonid Shifrin Mar 30 '12 at 13:48
  • 1
    $\begingroup$ @Leonid There is one good use case for writing one's own .mt runner: distributing tests together with an open source application so people can run it on different platforms without needing WorkBench. I really wish MUnit were part of Mathematica. $\endgroup$ – Szabolcs Apr 16 '13 at 2:04

Have a look at this post. There is a short explanation how to do it. I use this quite often and it works very well for me.

| improve this answer | |
  • $\begingroup$ Thanks, but this doesn't really answer the question. I want to use the same TestSuite construct that I use in Workbench outside of Workbench. $\endgroup$ – Ian Hinder Mar 30 '12 at 13:34

At least as of 10.3, Mathematica ships with MUnit included (I have not used prior versions, so I don't know when it was first included).

I was able to make it work with a script like this:

#! /usr/bin/env MathematicaScript -script

If[MUnit`TestRun["./Tests/MyPackageTestSuite.mt"], Exit[0], Exit[1]]

Which, of course, assumes that MathematicaScript is located somewhere on your PATH and you're running the script from the project root directory.

| improve this answer | |
  • $\begingroup$ It's included since 10.0. But unfortunately this version of MUnit is not compatible with the one in Workbench 2. To run test for projects made with Workbench, we still need to use the MUnit that ships with Workbench. $\endgroup$ – Szabolcs Dec 18 '15 at 8:38
  • $\begingroup$ @Szabolcs: Interesting. Could you share some examples of things that do not work outside of Workbench? $\endgroup$ – lebowski Dec 18 '15 at 18:30
  • $\begingroup$ So far I've been switching back and forth between the two with no problems - running tests on command line and only going to the Workbench when there're failed cases to examine. But I also haven't used all the features yet, such as child tests... $\endgroup$ – lebowski Dec 18 '15 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.