2012-05-28 125 views
1

我試圖創建一個使用SpecFlow行測試和微軟創建Rowtests內置的測試框架,沿着這些路線的東西:與SpecFlow

 
Scenario Outline: Test Calculator 
    Given I have entered <x> into the calculator 
    And I have entered <y> into the calculator 
    When I press add 
    Then the result should be <result> on the screen 

Examples: 
    | x | y | result| 
    | 1 | 2 | 3| 
    | 2 | 2 | 4| 

我面對的是,鑑於該方案的任何步驟中的問題爲示例表中的每個值自動生成一個單獨的步驟方法。我希望能夠爲每個步驟實現一個接收輸入值作爲參數的通用方法,但它似乎不工作。

回答

2

最終它看起來像它正常工作,我錯過了什麼是圍繞輸入參數佔位符報價:

 
Scenario Outline: Test Calculator 
    Given I have entered "<x>" into the calculator 
    And I have entered "<y>" into the calculator 
    When I press add 
    Then the result should be "<result>" on the screen 

Examples: 
    | x | y | result| 
    | 1 | 2 | 3| 
    | 2 | 2 | 4| 
+0

嗯奇怪。 [官方文檔](https://github.com/techtalk/SpecFlow/wiki/Unit-test-providers)說VS2010不支持rowtests。 – Jowen

+0

我有與VS 2012更新2相同的問題。奇怪的是,我寫了一些功能沒有報價在更新1,它的作品就像一個魅力。自那以後可能有些變化。 – Ouarzy

0

我在2012年VS有同樣的問題,我認爲這可能是一個錯誤SpecFlow,因爲當我將場景大綱更改爲只是場景時,它會正確生成所有內容。所有的文件說你不應該在引號中包圍佔位符。

總之,我的解決方案是將其更改爲方案以生成步驟。但是不要忘記,你必須將它改回到場景大綱來編譯。這是爲我工作的。