doh中有两种测试结构:
  1、Simple Tests  将一个单独的函数放到doh.register参数testCase数组里
  同步形式:
  function mySimpleTest(doh){
  doh.assertTrue(true);
  }
  异步形式:

 

function mySimpleAsyncTest(doh){
var deferred = new doh.Deferred();
setTimeout(deferred.getTestCallback(function(){
doh.assertTrue(true);
}), 100);
return deferred;
}

  2、Test Fixture
  同步形式:

 

{
name: "thingerTest",
setUp: function(){
// Setup to do before runTest.//类似于JUnit中的@beforeTest
this.thingerToTest = new Thinger();
this.thingerToTest.doStuffToInit();
},
runTest: function(){
// Our test function to run.//类似于JUnit中的@Test
doh.assertEqual("blah", this.thingerToTest.blahProp);
doh.assertFalse(this.thingerToTest.falseProp);
// ...
},
tearDown: function(){
// cleanup to do after runTest.//类似于JUnit中的@afterTest
},
timeout: 3000 // 3 second timeout.//测试运行时间,超过改时间会报错
}

  异步形式:

 

{
name: "thingerTest",
setUp: function(){
// Setup to do before runTest.
this.thingerToTest = new Thinger();
this.thingerToTest.doStuffToInit();
},
runTest: function(){
// Our test function to run.
var deferred = new doh.Deferred();
setTimeout(deferred.getTestCallback(function(){
doh.assertEqual("blah", this.thingerToTest.blahProp);
doh.assertFalse(this.thingerToTest.falseProp);
}), 100);
return deferred;
},
tearDown: function(){
// cleanup to do after runTest.
},
timeout: 3000 // 3 second timeout.
}