编写测试js文件的步骤
// 定义创建细则套件
describe("UnitTest:MainController", function () {
//定义细则
it("index method", function () {
//测试代码
expect(true).toBe(true);
})
})
编写测试js文件的步骤
1)使用describe函数把相关细则分组(测试命名成可读英文)
describe(specName,fn):创建细则套件
describe(‘UnitTest:MainController’,function(){})
describe(‘UnitTest:AccountController’,function(){
describe(‘index method’,function(){...})
})
2)it(specDesc,fn):定义细则,包含若干测试预期
it(‘contains a passing spec’,function(){...});
3)expect(val1).toBe(val2):创建测试预期,val1真实值,toBe()匹配器函数,val2期望值,创建否定式:expect(val1).not.toBe(val2)
来源:CSDN
作者:木木奕
链接:https://blog.csdn.net/arrisking/article/details/103697225