Per*_*Tew 16
var mySetupFunc(details){/* setup code */}
QUnit.testStart(mySetupFunc);
Run Code Online (Sandbox Code Playgroud)
从QUnit版本1.10.0pre-A开始,每个注册的回调将接收散列作为第一个(也是唯一的)参数.我在上面的例子中命名了我的'详细信息'.哈希的内容因回调而异.这是每个哈希中的信息列表.
开始
(开始所有测试)
{} /* empty hash */
Run Code Online (Sandbox Code Playgroud)
完成
(所有测试结束)
log
(在ok()方法中调用等)
testStart
(在每个测试开始时调用)
testDone
(在每次测试结束时调用)
moduleStart
(在每个模块的开头调用)
moduleDone
(在每次测试结束时调用)
// There's probably a more elegant way of doing this,
// but these two methods will add a row to a table for each test showing how long
// each test took.
var profileStartTime = null;
function startTimer(details) {
profileStartTime = new Date();
}
function stopTimer(details) {
var stopDate = new Date();
var duration = stopDate - profileStartTime;
jQuery('#profiling').append(
"<tr><td>"
+ (details.module ? details.module + ":" : "")
+ details.name
+ "<\/td><td class='duration'>"
+ duration
+ "<\/td><\/tr>");
}
QUnit.testStart(startTimer);
QUnit.testDone(stopTimer);
Run Code Online (Sandbox Code Playgroud)
我上面引用的html表如下所示:
<div style='margin: 10px 0;'>
<table summary='profiling' class='profiling_table'>
<thead>
<tr>
<th>Test Name</th>
<th>Duration</th>
</tr>
</thead>
<tbody id='profiling'>
</tbody>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5024 次 |
| 最近记录: |