0

Essentially I need help understanding this blog post:

http://www.sitepen.com/blog/2008/04/15/unit-testing-custom-code-with-the-dojo-objective-harness/

I want to use DOH to unit test an existing javascript project and I do not want to restructure that project to look like a Dojo widget. My project is structured like so:

project/
   scripts/
      doh/
         ...
      tests/
         testA.js
      project.js
   tests/
      tests.html
   index.html

tests.html is a page with a single link to:

../scripts/doh/runner.html?testModule=scripts.tests.testA

testA.js does not appear to be loading, and I'm not sure what code should go in it so that it loads correctly as a test suite and also has access to the classes defined in project.js.

4

1 回答 1

2

您的浏览器是否在其调试器工具中提供任何指示,说明它是否尝试加载名为 testA.js 的东西,如果是,从哪里加载?

如果您有路径问题(它可能正在寻找“脚本”作为您的 dojo 目录的同级目录),您可以在运行程序 URL 中提示 DOH 如何映射包,例如&registerModulePath=scripts,../../scripts(这会将“脚本”映射到'../../scripts';你需要适当地调整它,因为我看不到你的 Dojo 目录在哪里)

通常,您将“testModule”指向一个模块文件,这是一个简单地拉入测试夹具的文件,但我认为您只需指向一个测试夹具文件本身就可以逃脱。这只需要调用 doh.register 进行一些测试,然后使用 doh.run() 来启动它。

于 2012-05-10T12:40:24.967 回答