如何,可以说,在每次量角器规格测试后重新启动或关闭浏览器
How to, so to speak, restart or close browser after every protractor -spec test
我正在为网络应用程序实施 Protractor 测试。我已经进行了一些 google 搜索,但我想出了 zip,我希望我创建的每个规范在浏览器具有 运行 该特定规范文件中的所有测试后关闭浏览器,然后继续到下一个 -spec 文件,等等。我有诸如使用 "beforeAll" 和 "afterAll" 之类的东西,但 Jasmine 无法识别这些方法。指向正确的方向会很棒!
描述('i will put something more meaningful here later :)',函数(){
//not sure if this method actually exist in Jasmine
afterAll(function () {
//restart browser or something of the nature
});
it('should do stuff', function () {
});
it('do stuff', function () {
});
});
浏览器应关闭,然后重新打开至 运行 下一个规范。
说到在测试之间重启浏览器,有一个相关的配置选项:
// If true, protractor will restart the browser between each test.
// CAUTION: This will cause your tests to slow down drastically.
restartBrowserBetweenTests: false,
设置为true
。
仅供参考,这是初始功能请求:
beforeAll
和 afterAll
内置于 jasmine-2.x
。要使它们工作,您需要设置 jasmine2
as a testing framework in the protractor config:
exports.config = {
...
framework: 'jasmine2',
...
}
对于 jasmine-1.x
,有一个第三方 jasmine-beforeAll
包提供完全相同的功能。
在protractor.conf.js中:
capabilities:{
'shardTestFiles': true,
'maxInstances': 1
}
这将使用每个 .spec 文件打开和关闭浏览器,但您可能会失去标准插件的一些报告功能。如果 shardTestFiles 为 false,它将打开浏览器,运行 onPrepare,运行 所有测试串行,然后关闭浏览器。
我正在为网络应用程序实施 Protractor 测试。我已经进行了一些 google 搜索,但我想出了 zip,我希望我创建的每个规范在浏览器具有 运行 该特定规范文件中的所有测试后关闭浏览器,然后继续到下一个 -spec 文件,等等。我有诸如使用 "beforeAll" 和 "afterAll" 之类的东西,但 Jasmine 无法识别这些方法。指向正确的方向会很棒!
描述('i will put something more meaningful here later :)',函数(){
//not sure if this method actually exist in Jasmine
afterAll(function () {
//restart browser or something of the nature
});
it('should do stuff', function () {
});
it('do stuff', function () {
});
});
浏览器应关闭,然后重新打开至 运行 下一个规范。
说到在测试之间重启浏览器,有一个相关的配置选项:
// If true, protractor will restart the browser between each test.
// CAUTION: This will cause your tests to slow down drastically.
restartBrowserBetweenTests: false,
设置为true
。
仅供参考,这是初始功能请求:
beforeAll
和 afterAll
内置于 jasmine-2.x
。要使它们工作,您需要设置 jasmine2
as a testing framework in the protractor config:
exports.config = {
...
framework: 'jasmine2',
...
}
对于 jasmine-1.x
,有一个第三方 jasmine-beforeAll
包提供完全相同的功能。
在protractor.conf.js中:
capabilities:{
'shardTestFiles': true,
'maxInstances': 1
}
这将使用每个 .spec 文件打开和关闭浏览器,但您可能会失去标准插件的一些报告功能。如果 shardTestFiles 为 false,它将打开浏览器,运行 onPrepare,运行 所有测试串行,然后关闭浏览器。