我正在为我们使用specflow的c# .net核心应用程序接口编写一些集成测试。到目前为止,一切都很顺利,但我遇到了一个让我发疯的问题。我有以下几个场景:
Scenario: Test 1
Given I am ready
When I update invoice 1 of customer 2其方法定义如下:
[When(@"I update invoice (.*) of customer (.*)]
public async Task UpdateInvoiceCustomer(int invoiceId, int customerId)......第二个场景如下所示:
Scenario: Test 1
Given I am ready
When I update invoice 1 of customer 2 to ready其方法定义如下:
[When(@"I update invoice (.*) of customer (.*) to (.*)]
public async Task UpdateInvoiceCustomerStatus(int invoiceId, int customerId, string status)......我遇到的问题是VS无法区分这两者,并且不断尝试对测试1 c#代码运行测试2,但由于尝试将字符串"1 to active“转换为数字而失败。我认为肯定有一种方法可以检测到有三个参数,或者甚至可以通知specflow,字符串包含int,int,string不包含int,int,但我正在努力。顺便说一句,我可以通过重新编写字符串来解决这个问题--我不想这样做,因为必须有一个解决方案?
发布于 2021-04-15 16:15:44
参见Specflow step definitions -字符串需要用单引号括起来。所以你的例子应该是:
[When(@"I update invoice (.*) of customer (.*) to '(.*)'"]
public async Task UpdateInvoiceCustomerStatus(int invoiceId, int customerId, string status)而您的Specflow调用将是:
When I update invoice 1 of customer 2 to 'ready'https://stackoverflow.com/questions/67104573
复制相似问题