javascript - How to setup the Dojo Objective Harness test case structure for testing custom code? - Stack Overflow

I'm looking at using the Dojo Objective Harness (DOH) for testing some custom JavaScript code.To

I'm looking at using the Dojo Objective Harness (DOH) for testing some custom JavaScript code. To that end I've read the following article:

.html

and I have a question about the test case structure. The example shows that your test case modules in the same parent directory as dojo. This is a bit of a problem for us as we'd like to use DOH in multiple projects without having to include dojo in each and every one.

Does anyone know of a way to setup DOH to use the following structure:

  • dojotoolkit
    • dojo
    • dijit
    • dojox
    • util
  • project1
    • src
    • test
  • project2
    • src
    • test

Thanks...

Simon

I'm looking at using the Dojo Objective Harness (DOH) for testing some custom JavaScript code. To that end I've read the following article:

http://www.ibm./developerworks/web/library/wa-aj-doh/index.html

and I have a question about the test case structure. The example shows that your test case modules in the same parent directory as dojo. This is a bit of a problem for us as we'd like to use DOH in multiple projects without having to include dojo in each and every one.

Does anyone know of a way to setup DOH to use the following structure:

  • dojotoolkit
    • dojo
    • dijit
    • dojox
    • util
  • project1
    • src
    • test
  • project2
    • src
    • test

Thanks...

Simon

Share asked Jan 5, 2009 at 21:06 Simon MacDonaldSimon MacDonald 23.3k5 gold badges60 silver badges74 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

First of all let me refer to my previous answer — it contains some useful links you want to read first.

DOH can be used separately from Dojo, all you need is the "util" project where DOH resides. It has zero Dojo dependencies. In order to set it up for your own code, just take a look how Dojo does it. Usually the main file is called runTests.html. It is pretty much a boiler-plate, I just copy it over, and modify the URL in it to point to my own test module. For example, the Dojo Core tests' runTests.html uses "dojo.tests.module" ⇒ dojo/tests/module.js. Usually my directory is the peer to Dojo, so it will be something like "my.tests.module" located in my/tests/module.js or whatever I decide to name it.

Look in the Dojo's module.js — it includes other JavaScript files using dojo.require() (you can include and register your files with DOH without Dojo). It is possible to include files from different levels, or you can include a file (like dojo.tests._base) that includes more files. This is the way to make modular unit tests.

It is possible to include HTML files as well. For example, dojo.tests._base.html does it.

In short: it is simple, just read the docs, and use existing Dojo tests as a cheatsheet.

This article Unit Testing Custom Code with the Dojo Objective Harness http://www.sitepen./blog/2008/04/15/unit-testing-custom-code-with-the-dojo-objective-harness/ should give you what you need. It describes how to write unit tests for custom code in custom places.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744931464a4601764.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信