前端自动化测试工具doh学习总结(一)
作者:网络转载 发布时间:[ 2014/5/28 16:49:50 ] 推荐标签:自动化测试工具 doh
三、测试用例
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
相关推荐
更新发布
功能测试和接口测试的区别
2023/3/23 14:23:39如何写好测试用例文档
2023/3/22 16:17:39常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11