我知道我目前使用的是一个beforeEach()函数。
但是,我希望能够为我的父级“描述”运行一个前置函数,而不是在它们中运行“it”函数。
例如,我的测试如下(在beforeEach执行的函数前面有一个x):
beforeEach: login/out stuffs
x describe: create first case
x it: make selections
x it: add details
x it: change confidentiality settings
x it: etc
x describe: create second case
x it: make selections
x it: add details
x it: change confidentiality settings
x it: etc下面是我想让我的测试看起来的样子(在我希望beforeEach执行的函数前面有一个x):
beforeEach: login/out stuffs
x describe: create first case
it: make selections
it: add details
it: change confidentiality settings
it: etc
x describe: create second case
it: make selections
it: add details
it: change confidentiality settings
it: etc请提出一些解决办法。
发布于 2015-06-17 03:18:31
我解决这个问题的方法是将两个描述块分割成两个独立的规范文件。我觉得这样做更有意义,因为每个测试都需要满足不同的条件,而且拥有额外的规范文件也没什么麻烦。
发布于 2015-06-15 05:22:36
据我所知,为每个it从无到有地运行测试是一种意图设计选择。否则,它们都会进行状态更改,从而导致兄弟姐妹失败。
发布于 2015-06-16 00:49:48
您要查找的函数的名称是beforeAll()。您可以在每个描述中的所有之前添加一个。确保你在使用茉莉花2。
https://stackoverflow.com/questions/30837083
复制相似问题