在karate中,我们可以使用read()函数来读取示例表中的行号,并使用filter函数来过滤场景大纲。
下面是一个示例代码:
Feature: 示例
Background:
* url 'http://localhost:8080'
Scenario Outline: 示例场景
Given path '/api/users/'
When method GET
Then status 200
Examples:
| userId |
| 1 |
| 2 |
| 3 |
| 4 |
@ignore
| 5 |
| 6 |
| 7 |
| 8 |
Scenario: 使用过滤方案筛选场景大纲
* def rows = read('path/to/example.feature')
* def filteredRows = rows.filter(row => row.__rowIndex <= 4)
* print filteredRows
在上面的示例中,我们使用read()函数读取了示例表中的所有行,然后使用filter函数过滤出行号小于等于4的行,即示例表中的前4行。最后,我们使用print函数打印出过滤后的行。
执行以上代码,输出结果将会是:
| userId |
| 1 |
| 2 |
| 3 |
| 4 |
这样我们就成功地根据示例表中的行号筛选出了场景大纲中的特定行。