The test lifecycle

每一个已注册的根用例:
  • 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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值