量角器配置文件:cucumberOpts 标签未单独使用或忽略
Protractor config file: cucumberOpts tags not taken individually or ignored
我正在使用以下配置文件。
/*EC:201611*/
var featsLocation = 'features/';
var stepsLocation = 'steps/';
exports.config = {
params:{
authURL:'http://localhost:3333',
login:{
email:'',
passw:''
}
},
resultJsonOutputFile:'',
getPageTimeout: 60000,
allScriptsTimeout: 500000,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
capabilities: {
'browserName': 'phantomjs',
'phantomjs.binary.path': '/srv/build/applications/phantomjs/bin/phantomjs'
},
specs: [
featsLocation+'ediRejects.feature'
, featsLocation+'shipmentValidation.feature'
],
baseUrl: '',
cucumberOpts: {
tags: ['@Smoke','@Intgr'],
require: [
stepsLocation+'ediRejects/ediRejects.spec.js'
, stepsLocation+'shipmentValidation/shipmentValidation.spec.js'
, stepsLocation+'appointmentsOverdue/appointmentsOverdue.spec.js'
, stepsLocation+'deliveryOverdue/deliveryOverdue.spec.js'
, stepsLocation+'cpLogin/cpLogin.spec.js'
, stepsLocation+'globalSearch/globalSearch.spec.js'
, './support/hooks.js'
],
monochrome: true,
strict: true,
plugin: "json"
},
};
/*EC:201611*/
如您所见,我正在添加这些标签:['@Smoke','@Intgr']。
在功能文件中,我将标签放在场景之上,就像这样...
Feature: EDI-Rejects
@Smoke
Scenario: Access Final Mile Application
Given I get authentication to use EDI Rejects widget at Final Mile Application
@Smoke
Scenario: Validate title and headers
When I am testing EDI Rejects widget on the Werner Final Mile URL
Then Check the EDI Rejects widget header name is "EDI Rejects"
And Check the EDI Rejects Column Header names are "Customer Name", "Contact Name", "Contact Number", "Reject Reason", "Rejected %", "Shipper Ref #"
@Intgr
Scenario Outline: Validate Global Search Feature
When I am testing Global Search Feature of the Werner Final Mile URL
Then Check the "<columnName>" search is Correct
Examples:
| columnName |
| Customer Name |
| Contact Name |
| Contact No |
| Reject Reason |
| Shipper Reference Number |
但是当我执行时我得到这个...
0个场景
0 步
0m00.000s
我是不是漏掉了什么?
节点版本=v 7.2.0.
量角器版本=4.0.10.
npm 版本=3.10.9.
另外我注意到当我把这两个标签放在功能文件的同一个场景块中时,像这样...
@Smoke
@Intgr
Scenario: Access Final Mile Application
Given I get authentication to use EDI Rejects widget at Final Mile Application
@Smoke
@Intgr
Scenario: Validate title and headers
When I am testing EDI Rejects widget on the Werner Final Mile URL
Then Check the EDI Rejects widget header name is "EDI Rejects"
And Check the EDI Rejects Column Header names are "Customer Name", "Contact Name", "Contact Number", "Reject Reason", "Rejected %", "Shipper Ref #"
@Intgr
Scenario Outline: Validate Global Search Feature
When I am testing Global Search Feature of the Werner Final Mile URL
Then Check the "Customer Name" search is Correct
@Smoke
Scenario Outline: Validate Communication Methods disabled functionality
When I am testing Appointments Overdue widget on the Werner Final Mile URL
Then Check the Appointments Overdue widget "Phone" Communication button is disabled if none of the agents segments are selected
前两个场景被量角器选中,第三个和第四个被忽略。这对我不起作用,因为并非我所有的场景都是冒烟测试,也不是我所有的场景都是集成测试。
更新
我按照@Ram Pasala 的建议做了。但是现在使用 Cucumberjs2.0 我面临一个新问题:
我正在使用 package.json 到 运行 我的脚本和 npm test 命令。
这是曾经有效的 "old" 语法:
protractor ./FM_IntTest_UI_conf.js --cucumberOpts.tags ~@ignore --cucumberOpts.tags @smoke,@rt,@sprint
根据新的 cucumberjs 文档所说...
在老黄瓜js
This: --cucumberOpts.tags ~@ignore --cucumberOpts.tags @smoke,@rt,@sprint
在cucumberjs2.0
Becomes: --cucumberOpts.tags 'not @ignore and (@smoke or @rt)'
所以我尝试了:
protractor ./FM_IntTest_UI_conf.js --cucumberOpts.tags 'not @ignore and (@smoke or @rt)'
为了与 cucumberjs2.0 文档更加一致,我也尝试了:
protractor ./FM_IntTest_UI_conf.js --tags 'not @ignore and (@smoke or @rt)'
都没用。对于这两个,我都收到以下错误:
' was unexpected at this time.
C:\workspace> "C:\workspace\node_modules.bin\node.exe" "C:\workspace\node_modules.bin\..\protractor\bin\protractor"
./FM_IntTest_UI_conf.js ---tags 'not @ignor e and (@smoke or @rt)'
npm ERR! Test failed. See above for more details.
现在正确的语法是什么?
更新 (20170613)
经过反复试验,我发现了以下所有内容:
语法必须像这样使用双引号:
protractor ./FM_IntTest_UI_conf.js --tags "not @ignore and (@smoke or @rt)"
Cucumberjs 文档不正确。
要将其放入 package.json,需要转义字符:
"protractor ./FM_IntTest_UI_conf.js --tags \"not @ignore and (@smoke or @rt)\""
这里有几件事 -
tags
cli 选项接受字符串而不是数组 source-code。在 小于 2.0 的 cucumberJS 版本中,实际上被 protractor-cucumber-framework
模块使用,你可以像这样声明它们到 运行 @Smoke 或 @Intgr 场景 -
cucumberOpts: {
tags: '@Smoke,@Intgr'
}
这应该可以暂时解决您的问题。
但是从 Cucumber 2.0 开始,这会改变。它目前处于 RC(release-candidate)阶段,protractor-cucumber-framework 很快就会支持它,引入了许多重大变化,其中之一会影响 tags
表达式。根据他们的官方文档 cucumber-tag-expression 引入了更具可读性的新样式标签:
cucumberOpts: {
tags: '@Smoke or @Intgr'
}
//complex tags would become somewhat like this-
cucumberOpts: {
tags: '(@Smoke or @Intgr) and (not @Regression)'
}
我正在使用以下配置文件。
/*EC:201611*/
var featsLocation = 'features/';
var stepsLocation = 'steps/';
exports.config = {
params:{
authURL:'http://localhost:3333',
login:{
email:'',
passw:''
}
},
resultJsonOutputFile:'',
getPageTimeout: 60000,
allScriptsTimeout: 500000,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
capabilities: {
'browserName': 'phantomjs',
'phantomjs.binary.path': '/srv/build/applications/phantomjs/bin/phantomjs'
},
specs: [
featsLocation+'ediRejects.feature'
, featsLocation+'shipmentValidation.feature'
],
baseUrl: '',
cucumberOpts: {
tags: ['@Smoke','@Intgr'],
require: [
stepsLocation+'ediRejects/ediRejects.spec.js'
, stepsLocation+'shipmentValidation/shipmentValidation.spec.js'
, stepsLocation+'appointmentsOverdue/appointmentsOverdue.spec.js'
, stepsLocation+'deliveryOverdue/deliveryOverdue.spec.js'
, stepsLocation+'cpLogin/cpLogin.spec.js'
, stepsLocation+'globalSearch/globalSearch.spec.js'
, './support/hooks.js'
],
monochrome: true,
strict: true,
plugin: "json"
},
};
/*EC:201611*/
如您所见,我正在添加这些标签:['@Smoke','@Intgr']。 在功能文件中,我将标签放在场景之上,就像这样...
Feature: EDI-Rejects
@Smoke
Scenario: Access Final Mile Application
Given I get authentication to use EDI Rejects widget at Final Mile Application
@Smoke
Scenario: Validate title and headers
When I am testing EDI Rejects widget on the Werner Final Mile URL
Then Check the EDI Rejects widget header name is "EDI Rejects"
And Check the EDI Rejects Column Header names are "Customer Name", "Contact Name", "Contact Number", "Reject Reason", "Rejected %", "Shipper Ref #"
@Intgr
Scenario Outline: Validate Global Search Feature
When I am testing Global Search Feature of the Werner Final Mile URL
Then Check the "<columnName>" search is Correct
Examples:
| columnName |
| Customer Name |
| Contact Name |
| Contact No |
| Reject Reason |
| Shipper Reference Number |
但是当我执行时我得到这个...
0个场景 0 步 0m00.000s
我是不是漏掉了什么?
节点版本=v 7.2.0.
量角器版本=4.0.10.
npm 版本=3.10.9.
另外我注意到当我把这两个标签放在功能文件的同一个场景块中时,像这样...
@Smoke
@Intgr
Scenario: Access Final Mile Application
Given I get authentication to use EDI Rejects widget at Final Mile Application
@Smoke
@Intgr
Scenario: Validate title and headers
When I am testing EDI Rejects widget on the Werner Final Mile URL
Then Check the EDI Rejects widget header name is "EDI Rejects"
And Check the EDI Rejects Column Header names are "Customer Name", "Contact Name", "Contact Number", "Reject Reason", "Rejected %", "Shipper Ref #"
@Intgr
Scenario Outline: Validate Global Search Feature
When I am testing Global Search Feature of the Werner Final Mile URL
Then Check the "Customer Name" search is Correct
@Smoke
Scenario Outline: Validate Communication Methods disabled functionality
When I am testing Appointments Overdue widget on the Werner Final Mile URL
Then Check the Appointments Overdue widget "Phone" Communication button is disabled if none of the agents segments are selected
前两个场景被量角器选中,第三个和第四个被忽略。这对我不起作用,因为并非我所有的场景都是冒烟测试,也不是我所有的场景都是集成测试。
更新
我按照@Ram Pasala 的建议做了。但是现在使用 Cucumberjs2.0 我面临一个新问题:
我正在使用 package.json 到 运行 我的脚本和 npm test 命令。
这是曾经有效的 "old" 语法:
protractor ./FM_IntTest_UI_conf.js --cucumberOpts.tags ~@ignore --cucumberOpts.tags @smoke,@rt,@sprint
根据新的 cucumberjs 文档所说...
在老黄瓜js
This: --cucumberOpts.tags ~@ignore --cucumberOpts.tags @smoke,@rt,@sprint
在cucumberjs2.0
Becomes: --cucumberOpts.tags 'not @ignore and (@smoke or @rt)'
所以我尝试了:
protractor ./FM_IntTest_UI_conf.js --cucumberOpts.tags 'not @ignore and (@smoke or @rt)'
为了与 cucumberjs2.0 文档更加一致,我也尝试了:
protractor ./FM_IntTest_UI_conf.js --tags 'not @ignore and (@smoke or @rt)'
都没用。对于这两个,我都收到以下错误:
' was unexpected at this time. C:\workspace> "C:\workspace\node_modules.bin\node.exe" "C:\workspace\node_modules.bin\..\protractor\bin\protractor" ./FM_IntTest_UI_conf.js ---tags 'not @ignor e and (@smoke or @rt)'
npm ERR! Test failed. See above for more details.
现在正确的语法是什么?
更新 (20170613)
经过反复试验,我发现了以下所有内容:
语法必须像这样使用双引号:
protractor ./FM_IntTest_UI_conf.js --tags "not @ignore and (@smoke or @rt)"
Cucumberjs 文档不正确。
要将其放入 package.json,需要转义字符:
"protractor ./FM_IntTest_UI_conf.js --tags \"not @ignore and (@smoke or @rt)\""
这里有几件事 -
tags
cli 选项接受字符串而不是数组 source-code。在 小于 2.0 的 cucumberJS 版本中,实际上被 protractor-cucumber-framework
模块使用,你可以像这样声明它们到 运行 @Smoke 或 @Intgr 场景 -
cucumberOpts: {
tags: '@Smoke,@Intgr'
}
这应该可以暂时解决您的问题。
但是从 Cucumber 2.0 开始,这会改变。它目前处于 RC(release-candidate)阶段,protractor-cucumber-framework 很快就会支持它,引入了许多重大变化,其中之一会影响 tags
表达式。根据他们的官方文档 cucumber-tag-expression 引入了更具可读性的新样式标签:
cucumberOpts: {
tags: '@Smoke or @Intgr'
}
//complex tags would become somewhat like this-
cucumberOpts: {
tags: '(@Smoke or @Intgr) and (not @Regression)'
}