本文介绍了Mac 版 Wolfram Workbench 2.0 中 MUnit 的位置在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有适用于 Mac 的 Mathematica 8.0 和 Wolfram Workbench 2.0.我想使用 MUnit 对我正在创建的包进行单元测试,但我发现缺少有关 MUnit 的文档令人沮丧.

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.

最好的资源是 Sal Mangano 的数学食谱.第 19.11 节涵盖将 Wolfram Workbench 的 MUnit 包集成到前端".

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".

我想一旦我将 MUnit 暴露给前端,我将能够使用 ?.只是一个问题,我找不到 MUnit 包.我试图找到书中建议的 MUnit 目录:

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

,但没有任何运气.

推荐答案

如果您对这个答案投了赞成票,请也请给 Szabolcs 的答案投上赞成票,让他感到高兴.他在这方面提供了巨大的帮助.

MUnit 的位置取决于首次使用 Wolfram Workbench 功能的顺序.这只是一个理论,但它解释了为什么 find 最初无法找到 MUnit,但现在找到了. 在我的系统上,MUnit 位于:

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

要使用 Wolfram Workbench 在您的系统上定位 MUnit:

  1. 创建一个调用您的代码的测试用例.
  2. 在测试用例测试的代码中放置一个断点.
  3. 调试测试用例.
  4. 一旦你停在断点处,继续进入代码,最终当你进入TestID->"MyTest-20111230-L0X3S3"时,你将进入Test.m..立>
  5. 将鼠标悬停在 Test.m 的选项卡上,您将看到 Test.m 的位置.
  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.

使用find在您的系统上定位MUnit:

To locate MUnit on your system using find:

  1. 在 Wolfram Workbench 中创建一个测试用例.
  2. 打开终端并输入:find/-name MUnit -print 2>/dev/null

find 结果:

/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

找到位置后,您可以使用以下命令查询 MUnit 包: (注意:路径很可能略有不同)

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. *)

这篇关于Mac 版 Wolfram Workbench 2.0 中 MUnit 的位置在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 12:15