问题描述
我想在每个描述之后(而不是在每个测试用例之后)和每个描述之前做一些事情,有没有办法做到这一点?我尝试过以下格式,但它给我的错误是,在未定义之前和之后,是否可以在每个描述之前和之后执行一些任务:
I want to do something after each describe(not after each testcase) and before each describe, is there any way to do this? I have tried below format, but it gives me error that, before and after not defined, is it possible to do sometask before and after of each describe:
describe('testcase', function () {
before(function () {
--------------
})
beforeEach(function () {
-----------------
})
afterEach(function () {
--------------
})
after(function () {
-----------------
})
it('task1', function () {
-----------
})it('task2', function () {
------------------
})
})
推荐答案
据我了解,你想要 jasmine 2.1中引入的rel="nofollow">beforeAll
和afterAll
:
As far as I understand, you want beforeAll
and afterAll
which were introduced in jasmine 2.1
:
beforeAll 函数在所有规范之前只调用一次describe 运行,并且在所有规范之后调用 afterAll 函数结束.这些功能可用于加速测试套件昂贵的设置和拆卸.
对于较旧的 jasmine
版本,同样可以在 的帮助下完成jasmine-beforeAll
包.
For the older jasmine
versions, the same can be done with the help of jasmine-beforeAll
package.
这篇关于在使用 angularjs 的 selenium 服务器的量角器中做一些事后描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!