我有几个测试可以进行回归测试。测试不是相互依赖的,但是它们需要很长时间才能顺序执行。我以为我可以 并行执行它们,可能是2或3个线程或实例 。
规格文件是 protractor-cucumber-jscript,功能是小黄瓜。
一旦完成,我将通过Jenkins工作执行。
是否可以使用量角器配置文件进行设置?我想在每个实例中执行不同的功能和规范。
我尝试了以下操作,但未成功:
var featsLocation = 'features/';
var stepsLocation = 'steps/';
exports.config = {
rootElement: 'html',
chromeDriver: './srv/build/applications/chromedriver/chromedriver_win32/chromedriver.exe',
seleniumServerJar: './node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone.jar',
params:{
authURL:'',
login:{
email:'',
passw:''
}
},
resultJsonOutputFile:'',
getPageTimeout: 60000,
allScriptsTimeout: 60000,
maxSessions: 2,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
multiCapabilities:[
{
browserName: 'chrome',
chromeOptions:{
args:["--headless"]
},
name: 'CAPABILITY_1',
logName: 'LOGNAME1_USERNAME1_A',
shardTestFiles: false,
maxInstances: 1,
count: 1,
specs: [ featsLocation+'authenticateCSM.feature'
, featsLocation+'locationSearch.feature'
]
},{
browserName: 'chrome',
chromeOptions:{
args:["--headless"]
},
name: 'CAPABILITY_2',
logName: 'LOGNAME1_USERNAME2_B',
shardTestFiles: false,
maxInstances: 1,
count: 1,
specs: [ featsLocation+'authenticateCSM.feature'
, featsLocation+'shipmentErrors.feature'
]
}],
onPrepare: function(){
global.EC = protractor.ExpectedConditions;
},
baseUrl: '',
cucumberOpts: {
tags: '',
require: [
'./support/*.js'
, stepsLocation+'shipmentErrors/shipmentErrors.spec.js'
, stepsLocation+'locationSearch/locationSearch.spec.js'
],
monochrome: true,
strict: true,
plugin: "json"
},
};
使用package.json传递URL和其他参数。
执行时,我会得到两个执行黄瓜功能的selenium驱动程序实例,但每个浏览器只执行一个功能。
我的配置文件语法是否有问题...我应该如何构建它?
更新更新更新更新
经过 yong 的一些更新后,配置文件如下所示:
var featsLocation = 'features/';
var stepsLocation = 'steps/';
exports.config = {
rootElement: 'html',
chromeDriver: 'C:\\srv\\build\\applications\\chromedriver\\chromedriver_win32\\chromedriver.exe',
seleniumServerJar: './node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone.jar',
params: {
authURL: '',
login: {
email: '',
passw: ''
}
},
resultJsonOutputFile: '',
getPageTimeout: 60000,
allScriptsTimeout: 60000,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ["--headless"]
},
shardTestFiles: true,
maxInstances: 2,
count: 1,
},
onPrepare: function () {
global.EC = protractor.ExpectedConditions;
browser.ignoreSynchronization = true;
process.on('unhandledRejection', function (reason, pr) {
console.log("Unhandled promise at:", pr, "Reason: ", reason);
});
global.EC = protractor.ExpectedConditions;
browser.ignoreSynchronization = true;
},
specs: [
featsLocation + 'authenticateCSM.feature',
featsLocation + 'shipmentErrors.feature',
featsLocation + 'locationSearch.feature'
],
baseUrl: '',
cucumberOpts: {
tags: '',
require: [
'./support/*.js',
stepsLocation + 'shipmentErrors/shipmentErrors.spec.js',
stepsLocation + 'locationSearch/locationSearch.spec.js'
],
monochrome: true,
strict: true,
plugin: "json"
},
};
现在发生的事情是:
现在,我有以下问题:
答案 0 :(得分:0)
根据Protractor Configuration file guide,您可以为每项功能指定specs
:
* Example:
* capabilities: {
* browserName: 'chrome',
* name: 'Unnamed Job',
* logName: 'Chrome - English',
* count: 1,
* shardTestFiles: false,
* maxInstances: 1,
* specs: ['spec/chromeOnlySpec.js'],
* exclude: ['spec/doNotRunInChromeSpec.js'],
* seleniumAddress: 'http://localhost:4444/wd/hub'
* }
您可以尝试使用multiCapabilities
添加不同specs
的2个功能:
multiCapabilities: [
capabilities: {
browserName: 'chrome',
logName: 'Chrome - Suite 1',
shardTestFiles: true,
maxInstances: 2,
specs: ['suite 1 specs']
},
capabilities: {
browserName: 'firefox',
logName: 'Firefox - Suite 2',
shardTestFiles: true,
maxInstances: 2,
specs: ['suite 2 specs']
}
]
我之前从未练习过,所以我不确定它是否符合您的要求。
我在上面的代码示例中指出了不同的browserName
功能,练习时可以尝试使用相同的browserName
。
而且我不确定运行结果是否可以写入同一个文件,所有人都在等着你找出答案。您可以尝试使用此程序包:protractor-multiple-cucumber-html-reporter-plugin用于HTML报告。