每一个已注册的根用例:
- The setup method of the suite is called, if it exists
- For each test within the suite:
- The beforeEach method of the suite is called, if it exists
- The test function is called
- The afterEach method of the suite is called, if it exists
- The teardown method of the suite is called, if it exists
So, given the this test module:
define(function (require) {
var registerSuite = require('intern!object');
registerSuite({
setup: function () {
console.log('outer setup');
},
beforeEach: function () {
console.log('outer beforeEach');
},
afterEach: function () {
console.log('outer afterEach');
},
teardown: function () {
console.log('outer teardown');
},
'inner suite': {
setup: function () {
console.log('inner setup');
},
beforeEach: function () {
console.log('inner beforeEach');
},
afterEach: function () {
console.log('inner afterEach');
},
teardown: function () {
console.log('inner teardown');
},
'test A': function () {
console.log('inner test A');
},
'test B': function () {
console.log('inner test B');
}
},
'test C': function () {
console.log('outer test C');
}
});
}); …the resulting console output would be in this order:
outer setup inner setup outer beforeEach inner beforeEach inner test A inner afterEach outer afterEach outer beforeEach inner beforeEach inner test B inner afterEach outer afterEach inner teardown outer beforeEach outer test C outer afterEach outer teardown
本文深入解析了测试套件的执行流程,包括setup、beforeEach、afterEach和teardown方法的调用顺序,通过具体代码示例展示了如何在测试模块中组织和执行测试用例。
2997

被折叠的 条评论
为什么被折叠?



