cypress-cucumber-preprocessor 数据表
cypress-cucumber-preprocessor Datatables
我看到了一些与我的相似的 post 但我发现它根本没有帮助,因为 none 他们中的 none 使用了 cypress 预处理器。
我有一个场景:
Scenario: Some scenario
Given ...
When ...
Then I should see "<task_field>" field as "<field_value>"
Examples:
| task_field | field_value |
| some_field1 | some_value1 |
| some_field2 | some_value2 |
| some_field3 | some_value3 |
.js 文件有:
Then('I should see {string} field as {string}', (field, value ) => {
switch (field) {
case 'some_field1':
cy.get('.someClass1').contains(value)
break
case 'some_field2':
cy.get('.someClass2').contains(value)
break
case 'some_field3':
cy.get('.someClass3').contains(value)
break
default:
throw new Error(`Invalid field: ${field}`)
}
})
我的目标是检查每个 some_field 是否等于 some_value,但目前 cypress 向我抛出一个错误,它甚至没有给我执行测试的选项:
如有任何帮助,我们将不胜感激
干杯!
调试 2 小时后,我发现我忘记在场景定义中包含 Outline
世界,以便测试能够遍历数据 table。
因此,为了将来参考修复:
Scenario: Some scenario
Given ...
When ...
Then I should see "<task_field>" field as "<field_value>"
Examples:
| task_field | field_value |
| some_field1 | some_value1 |
| some_field2 | some_value2 |
| some_field3 | some_value3 |
就是在第一行包含Outline
:
Scenario Outline: Some scenario
Given ...
When ...
Then I should see "<task_field>" field as "<field_value>"
Examples:
| task_field | field_value |
| some_field1 | some_value1 |
| some_field2 | some_value2 |
| some_field3 | some_value3 |
我认为这对我来说是漫长的一天。
希望这对遇到类似问题的人有所帮助!
我看到了一些与我的相似的 post 但我发现它根本没有帮助,因为 none 他们中的 none 使用了 cypress 预处理器。
我有一个场景:
Scenario: Some scenario
Given ...
When ...
Then I should see "<task_field>" field as "<field_value>"
Examples:
| task_field | field_value |
| some_field1 | some_value1 |
| some_field2 | some_value2 |
| some_field3 | some_value3 |
.js 文件有:
Then('I should see {string} field as {string}', (field, value ) => {
switch (field) {
case 'some_field1':
cy.get('.someClass1').contains(value)
break
case 'some_field2':
cy.get('.someClass2').contains(value)
break
case 'some_field3':
cy.get('.someClass3').contains(value)
break
default:
throw new Error(`Invalid field: ${field}`)
}
})
我的目标是检查每个 some_field 是否等于 some_value,但目前 cypress 向我抛出一个错误,它甚至没有给我执行测试的选项:
如有任何帮助,我们将不胜感激 干杯!
调试 2 小时后,我发现我忘记在场景定义中包含 Outline
世界,以便测试能够遍历数据 table。
因此,为了将来参考修复:
Scenario: Some scenario
Given ...
When ...
Then I should see "<task_field>" field as "<field_value>"
Examples:
| task_field | field_value |
| some_field1 | some_value1 |
| some_field2 | some_value2 |
| some_field3 | some_value3 |
就是在第一行包含Outline
:
Scenario Outline: Some scenario
Given ...
When ...
Then I should see "<task_field>" field as "<field_value>"
Examples:
| task_field | field_value |
| some_field1 | some_value1 |
| some_field2 | some_value2 |
| some_field3 | some_value3 |
我认为这对我来说是漫长的一天。 希望这对遇到类似问题的人有所帮助!