SpecFlow 相当新,所以请多多包涵。
我正在与一位同事一起工作,以基本了解您可以使用 SpecFlow 做什么。
我们使用的是经典的 FizzBuzz 问题,我们用它来测试单元测试,以比较我们如何在 SpecFlow 中解决类似问题。
我们编写了如下场景,根据需要增加代码:
(请原谅命名只是想获得测试令)
Scenario: 1 is 1
Given there is a FizzBuzzFactory
When you ask What I Am with the value of 1
Then the answer should be 1 on the screen
Scenario: 3 is Fizz
Given there is a FizzBuzzFactory
When you ask What I Am with the value of 3
Then the answer should be Fizz on the screen
Scenario: 5 is Buzz
Given there is a FizzBuzzFactory
When you ask What I Am with the value of 5
Then the answer should be Buzz on the screen
Scenario: 15 is FizzBuzz
Given there is a FizzBuzzFactory
When you ask What I Am with the value of 15
Then the answer should be FizzBuzz on the screen
这导致了一种发展,以开发一种计算某些数字之和的方法
我们写的场景是:
Scenario: Sumof 1 + 2 + 3 is Fizz
Given there is a FizzBuzzFactory
When you add the sum of 1
When you add the sum of 2
When you add the sum of 3
Then the answer should be Fizz on the screen
我们写的方法一次接受一个数字然后总结。
理想情况下,我会提供:
Scenario: Sumof 1 + 2 + 3 in one go is Fizz
Given there is a FizzBuzzFactory
When you add the sum of 1,2,3
Then the answer should be Fizz on the screen
您如何着手设置语句,以便您可以期待params int[]
方法签名。