您的位置:首页 > Web前端

The test lifecycle

2016-04-13 17:31 375 查看
每一个已注册的根用例:
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: