2014 年 2 月更新 - 此答案不再有效。在下面使用 Paolo Moretti 的答案。
可能有更好的方法来做到这一点,但目前我只是将这些作为并发的 Grunt 任务执行。
1) 添加 grunt 并发插件
npm install grunt-concurrent --save-dev
2) 在 grunt.initConfig 下为每个浏览器添加一个任务。我们可以将浏览器添加为 arg 以重用我们的配置文件。
protractor: {
options: {
keepAlive: true,
singleRun: false,
configFile: "test/protractor.conf.js"
},
run_chrome: {
options: {
args: {
browser: "chrome"
}
}
},
run_firefox: {
options: {
args: {
browser: "firefox"
}
}
}
},
3)将这些注册为任务;
grunt.registerTask('protractor-chrome', ['protractor:run_chrome']);
grunt.registerTask('protractor-firefox', ['protractor:run_firefox']);
4) 在 grunt.initConfig 下创建你的并发任务
concurrent: {
protractor_test: ['protractor-chrome', 'protractor-firefox']
},
5) 为并发添加 grunt 任务
grunt.registerTask('protractor-e2e', ['concurrent:protractor_test']);
执行它应该会给你并发量角器测试。