量角器:在prepare针对不同的测试套件量角器、套件、不同、测试

由网友(我呸!伱滚)分享简介:我有prepare在我conf.js文件,我登录到应用程序。我的理解是每次​​运行1个或多个测试套件时,它首先执行无论是在上prepare。这是伟大的,因为我用prepare登录到应用程序在运行测试之前。I have onPrepare in my conf.js file where I log in to the...

我有prepare在我conf.js文件,我登录到应用程序。我的理解是每次​​运行1个或多个测试套件时,它首先执行无论是在上prepare。这是伟大的,因为我用prepare登录到应用程序在运行测试之前。

I have onPrepare in my conf.js file where I log in to the application. My understanding is every time I run 1 or more test suites, it first executes whatever is in onPrepare. This is great, as I use onPrepare to log into the application before running the tests.

问题是,我不想登录时,我跑我的login-spec.js套件。

Issue is, I don't want to login when I run my login-spec.js suite.

我可以先通过登录-spec.js运行前注销,但必须有一个更优雅的方式来做到这一点。

I could first logout before running through login-spec.js, but there must be a more elegant way to do this.

推荐答案

据我了解,你需要对特定的套房preparations的地方。

As far as I understand, you need a place for suite-specific preparations.

这是什么茉莉可以帮你。

有关茉莉 2.1及以上,还有内置的 beforeAll 毕竟 符号:

For jasmine 2.1 and above, there are built-in beforeAll and afterAll notations:

该beforeAll功能在所有的规格之前只调用一次  描述被运行,并且毕竟函数所有规格后称为  完。这些功能可以用于与以加快测试套件  昂贵的安装和拆卸。

The beforeAll function is called only once before all the specs in describe are run, and the afterAll function is called after all specs finish. These functions can be used to speed up test suites with expensive setup and teardown.

如果您使用的是旧的茉莉的版本,使用一个单独的 茉莉花beforeAll 包。

If you are on an older jasmine version, use a separate jasmine-beforeAll package.

阅读全文

相关推荐

最新文章