三、测试用例
  doh为我们提供了以下断言函数:

 

doh.assertTrue(boolean)
Note: This function is aliased to doh.t();
doh.assertFalse(boolean)
Note: This function is aliased to doh.f();
doh.assertEqual(obj1, obj2)
Note: This function is aliased to doh.is();
doh.assertNotEqual(obj1, obj2)
Note: This function is aliased to doh.isNot();

  Junit中,编写一个测试用例我们需要继承Junit类,同样在doh中也有自己的规则来将一段代码,包装成doh可识别的测试案例。

  doh中主要提供了以下方法(常用的是doh.register):

 

doh.register(...)
An almost 'magical' function. The doh.register() method accepts the function signatures of any of the other registration functions and determines the correct underlying function (listed below) to dispatch registration to. It's the function you'll most commonly use for registering Unit Tests.
doh.registerTest(group, testFuncOrObj)
This function registers a test as a member of the group 'group', and the test can either be a simple function definition or a 'Test Fixture', which is an object that defines the run requirements of the test.
doh.registerTests(group, testFuncOrObjArr)
This function registers an array of tests as a member of the group 'group'. The contents of the array of tests can be an array of simple test functions or an array of 'test fixtures', or a mix of them.
doh.registerTestNs(group, obj)
This function registers an object comprised of functions as a member of the group 'group'. Note that this function will only add in non-private (functions without an _ at the beginning of the name), as a test function. If you'd like to use fixtures (setUp(), tearDown(), and runTest()), please use doh.register(), doh.registerTest() or doh.registerTests().
doh.registerTestUrl(url)
This function registers a URL as a location to load tests from. The URL is used to populate the contents of an iframe, and usually refers to an HTML page that boot-loads D.O.H. internally for running tests in a segmented iframe. A good example showing this is the dojo/tests/fx.html. It loads dojo, doh, and then on dojo load completion calls doh.registerTests(). The D.O.H. instance in the iframe will proxy back the results of the test run to the primary D.O.H. instance.

  上面提到的dojo/test/fx模块中我们可以看到该文件中主要定义了两个TestSuite:
  define(["doh/main", "require"], function(doh, require){
  if(doh.isBrowser){
  doh.register("tests.fx", require.toUrl("./fx.html"), 30000);
  doh.register("tests.NodeList-fx", require.toUrl("./NodeList-fx.html"), 30000);
  }
  });
  对应于runner.html中

  打开该目录下的fx.html文件,我们可以看到该文件中定义了一系列TestCase