最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论