SpecFlow and complex objects

前端 未结 7 910
旧巷少年郎
旧巷少年郎 2020-12-23 17:57

I\'m evaluating SpecFlow and I\'m a bit stuck.
All samples I have found are basically with simple objects.

Project I\'m working on heavily relies on a complex ob

7条回答
  •  粉色の甜心
    2020-12-23 18:05

    I have worked at several organisations now that have all ran into the same issue you describe here. This is one of the things that prompted me to (attempt) to start writing a book on the subject.

    http://specflowcookbook.com/chapters/linking-table-rows/

    Here I suggest using a convention which allows you to use the specflow table headers to indicate where the linked items come from, how to identify which ones you want, and then use the content of the rows to provide the data to "lookup" in the foreign tables.

    For instance:

    Scenario: Letters to Santa appear in the emailers outbox
    
    Given the following "Children" exist
    | First Name | Last Name | Age |
    | Noah       | Smith     | 6   |
    | Oliver     | Thompson  | 3   |
    
    And the following "Gifts" exist
    | Child from Children    | Type     | Colour |
    | Last Name is Smith     | Lego Set |        |
    | Last Name is Thompson  | Robot    | Red    |
    | Last Name is Thompson  | Bike     | Blue   |
    

    Hopefully this will be of some assistance.

提交回复
热议问题