QUnit单元测试文档
作者:网络转载 发布时间:[ 2014/12/10 14:04:52 ] 推荐标签:软件测试 单元测试
//region Configuration
//assert Namespace for QUnit assertions
QUnit.test( "`ok` assertion defined in the callback parameter", function ( assert ) {
assert.ok( true, "on the object passed to the `test` function" );
} );
//config Configuration for QUnit
QUnit.config.autostart = false;
QUnit.config.current.testName = "zodiac";
QUnit.config.urlConfig.push( {
id : "jquery",
label : "jQuery version",
value : [ "1.7.2", "1.8.3", "1.9.1" ],
tooltip : "What jQuery Core version to test against"
} );
//QUnit.dump.parse() 它解析数据结构和对象序列化为字符串。也解析DOM元素outerHtml为字符串
QUnit.log( function ( obj ) {
// Parse some stuff before sending it.
var actual = QUnit.dump.parse( obj.actual );
var expected = QUnit.dump.parse( obj.expected );
// Send it.
} );
var qHeader = document.getElementById( "qunit-header" ),
parsed = QUnit.dump.parse( qHeader );
console.log( parsed );
// Logs: "<h1 id="qunit-header"></h1>"
//QUnit.extend() Copy the properties defined by the mixin object into the target object
QUnit.test( "QUnit.extend", function ( assert ) {
var base = {
a : 1,
b : 2,
z : 3
};
QUnit.extend( base, {
b : 2.5,
c : 3,
z : undefined
} );
assert.equal( base.a, 1, "Unspecified values are not modified" );
assert.equal( base.b, 2.5, "Existing values are updated" );
assert.equal( base.c, 3, "New values are defined" );
assert.ok( !( "z" in base ), "Values specified as `undefined` are removed" );
} );
//endregion
相关推荐
更新发布
功能测试和接口测试的区别
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