我在 Protractor 中创建了几个测试(规范)——每个测试在单独运行时都能正常工作。问题是当它们作为一个套件执行时 - 测试中断。 我想在测试之间添加一些操作 - 例如超时或注销。 有选择吗? 我试过在这里看: https://github.com/angular/protractor/blob/master/docs/referenceConf.js
这是我的 conf.js 文件(规范部分):
suites:{
sanity: ['*/AccountSettingsTest.js','*/createApptest.js']
},
specs: ['*/AccountSettingsTest.js'],
谢谢
最佳答案
我相信你可以使用 jasmine afterAll
函数。它应该在测试中的 describe block 之后运行。只需将注销/超时功能放入 describe
block 内的 afterAll
block 中,对于该规范文件,它将在 describe 之后运行。由于您有多个规范,我想您会希望在每个规范文件中都有它,因为文件运行的顺序可能会有所不同。
来自jasmine docs :
describe("A spec using beforeAll and afterAll", function() {
var foo;
beforeAll(function() {
foo = 1;
});
afterAll(function() {
foo = 0;
});
it("sets the initial value of foo before specs run", function() {
expect(foo).toEqual(1);
foo += 1;
});
it("does not reset foo between specs", function() {
expect(foo).toEqual(2);
});
});
关于 Protractor - 套件中规范之间的 Action ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32177091/