Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the location of MUnit in Wolfram Workbench 2.0 for the Mac?

I have Mathematica 8.0 and Wolfram Workbench 2.0 for the Mac. I want to use MUnit to unit test a package I am creating, but I am finding the lack of documentation on MUnit to be frustrating.

The best resource so for has been Mathematic Cookbook by Sal Mangano. Section 19.11 covers "Integrating Wolfram Workbench’s MUnit Package into the Frontend".

I figure once I expose MUnit to the frontend, I will be able to query the MUnit API with ? . Just one problem, I can't find the MUnit package. I tried to locate the MUnit directory as suggested in the book with:

find / -name MUnit -print 2> /dev/null

, but have not had any luck.

like image 412
mmorris Avatar asked Dec 30 '11 21:12

mmorris


1 Answers

If you up vote this answer, please show Szabolcs some luv by up voting his answer too. He was a tremendous help on this.

The location of MUnit is dependent upon the order that features of Wolfram Workbench were first used. That is just a theory, however it explains why find was not able to find MUnit initially, but finds it now. On my system MUnit is located at:

/Applications/Wolfram\ Workbench.app/configuration/org.eclipse.osgi/bundles/214/1/.cp/MathematicaSourceVersioned/Head/MUnit

To locate MUnit on your system using Wolfram Workbench:

  1. Create a test case that calls your code.
  2. Place a break point in your code that is tested by the test case.
  3. Debug the test case.
  4. Once you stop at the break point, keep stepping into the code and eventually you will step into Test.m when you step into TestID->"MyTest-20111230-L0X3S3".
  5. Hover the mouse over the Tab for Test.m and you will see the location of Test.m.

location to Test.m in Mac version

To locate MUnit on your system using find:

  1. Create a test case in Wolfram Workbench.
  2. Open terminal and type: find / -name MUnit -print 2> /dev/null

find results:

/Applications/Wolfram Workbench.app/configuration/org.eclipse.osgi/bundles/214/1/.cp/MathematicaSourceVersioned/Head/MUnit
/Applications/Wolfram Workbench.app/configuration/org.eclipse.osgi/bundles/214/1/.cp/MathematicaSourceVersioned/Version5.2/MUnit
/Applications/Wolfram Workbench.app/configuration/org.eclipse.osgi/bundles/214/1/.cp/MathematicaSourceVersioned/Version6/MUnit

Once you find the location you can query the MUnit package with: (note: the path most likely be slightly different)

AppendTo[$Path, 
  FileNameJoin[{"/", "Applications", "Wolfram Workbench.app", 
    "configuration", "org.eclipse.osgi", "bundles", "214", "1", ".cp",
     "MathematicaSourceVersioned", "Head", "MUnit"}]];
Needs["MUnit`"];
?MUnit`*
(* Need a blank line after ?MUnit`* otherwise a nasty message is generated. *)
like image 112
mmorris Avatar answered Nov 15 '22 20:11

mmorris