specflow:在 c# 中从文件和 运行 场景异步提供数据
specflow: feed data from a file and run scenarios async in c#
有这个feature
:
Feature: ServiceAdd
Check if addition works well
@someTest
Scenario: Add two numbers
Given I connected to the api
And I check the result
| a | b | ExpectedResult |
| 1 | 2 | 3 |
| 4 | 2 | 6 |
| -1| 2 | 1 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
和c#
代码:
[Given(@"I check the result")]
public void GivenICheckTheResult(Table table)
{
......
}
我有一些问题:
- 如何运行对table中的所有值进行测试
async
(我不想等待结果开始新的测试)?
- 如何从文件或数据库中提供这些值,以便测试自动读取这些值?
您需要使用支持 运行 并行测试的测试运行器。我相信目前是 NUnit3、XUnit2、SpecRun 或 NCrunch。
你或许可以为此使用 Specflow+ excel extension,虽然我没有使用过它所以不能确定它是否适合这个用例,而且它是一个付费扩展。
有这个feature
:
Feature: ServiceAdd
Check if addition works well
@someTest
Scenario: Add two numbers
Given I connected to the api
And I check the result
| a | b | ExpectedResult |
| 1 | 2 | 3 |
| 4 | 2 | 6 |
| -1| 2 | 1 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
和c#
代码:
[Given(@"I check the result")]
public void GivenICheckTheResult(Table table)
{
......
}
我有一些问题:
- 如何运行对table中的所有值进行测试
async
(我不想等待结果开始新的测试)? - 如何从文件或数据库中提供这些值,以便测试自动读取这些值?
您需要使用支持 运行 并行测试的测试运行器。我相信目前是 NUnit3、XUnit2、SpecRun 或 NCrunch。
你或许可以为此使用 Specflow+ excel extension,虽然我没有使用过它所以不能确定它是否适合这个用例,而且它是一个付费扩展。