0
votes

I am trying to migrate from specflow excel to using a json data file and the external data plugin

Related to Specflow - using data from external file in feature file is there a walkthrough to setup a feature file, and json data file with new @property approach to data?

I have a Specflow feature like this, which originally came from Specflow Excel.

Feature: EndToEndId

Scenario Outline: Single Payment
    Given a client <clientNo> called <cName>
    And a broker <bName> with book ref <bRef>
    When a deal to <buyOrSell> an amount <fromAmt> of <ccy1> for <ccy2> for value <vDate> at client rate <cRate> and bank rate <bRate>
    Then create a deal <dealNo> with client amt <toCAmt> and cover amt <coverAmt> and PnL <PnL> and profit rate <pRate> and <bYes>
    And add beneficiary <benName> and country <ctry> and pay type <payType> and charge <charge> and <abYes>
    When a credit file <c1> with <c1Name> for <c1Amt> <c1Ccy> for value <c1Date> with ref <EndToEndId1>
    Then CreditNotice gets <fIn1Type> for client <fIn1Client>

Examples: 
    | case                 | clientNo | cName        | bName   | bRef       | buyOrSell | fromAmt | ccy1 | ccy2 | vDate | cRate             | bRate             | dealNo | toCAmt           | coverAmt         | PnL     | pRate    | bYes | benName     | ctry | payType | charge | abYes | c1    | c1Name           | c1Amt            | c1Ccy | c1Date | EndToEndId1      | fIn1Type       | fIn1Client       |
    | T1: 99549 ######     | 99549    | Gherkin Test | MERCURY | 01W3RG5638 | SELL      | 100000  | EUR  | GBP  | SP    | 0.89435           | 0.89935           | ###### | 89435            | 89935            | 500     | 1        | yes  | Gherkin Ben | GB   | CHAPS   | NONE   | yes   | 99549 | Gherkin Test     | 100000           | EUR   | SP     | 99549 ######     | FullFundsIn    | Gherkin Test     |

To use the with a json file for the data, am I going to need to define each property again like this:

@property:clientNo=clientNo
@property:cName=cName
@property:bName=bName

and a json data file like this:

{
    "case": "T-9: 99549 ######",
    "clientNo": "99549",
    "cName": "Gherkin Test",
    "bName": "MERCURY",
    "bRef": "01W3RG5638",
    "buyOrSell": "SELL",
    "fromAmt": "100,000",
    "ccy1": "EUR",
    "ccy2": "GBP",
    "vDate": "SP",
    "cRate": " 0.894350 ",
    "bRate": " 0.894350 ",
    "dealNo": "######",
    "toCAmt": "89,435.00",
    "coverAmt": "89,435.00",
    "PnL": "0.00",
    "pRate": " 1.000000 ",
    "bYes": " yes ",
    "benName": "Gherkin Ben",
    "ctry": "GB",
    "payType": "CHAPS",
    "charge": "NONE",
    "abYes": "yes",
    "c1": "99549",
    "c1Name": "Gherkin Test",
    "c1Amt": "100,000",
    "c1Ccy": "EUR",
    "c1Date": "SP",
    "EndToEndId1": "99549 ######",
    "fIn1Type": "FullFundsIn",
    "fIn1Client": "Gherkin Test"
},
{
    "case": "T-8: 1234 1234",
    "clientNo": "99549",
    "cName": "Gherkin Test",
    "bName": "JUPITER",
    "bRef": "01W3RG5639",
    "buyOrSell": "SELL",
    "fromAmt": "200,000",
    "ccy1": "EUR",
    "ccy2": "GBP",
    "vDate": "SP",
    "cRate": " 0.894350 ",
    "bRate": " 0.894350 ",
    "dealNo": "######",
    "toCAmt": "178,870.00",
    "coverAmt": "178,870.00",
    "PnL": "0.00",
    "pRate": " 1.000000 ",
    "bYes": " yes ",
    "benName": "Gherkin Ben",
    "ctry": "GB",
    "payType": "FASTER",
    "charge": "NONE",
    "abYes": "yes",
    "c1": "99549",
    "c1Name": "Gherkin Test",
    "c1Amt": "200,000",
    "c1Ccy": "EUR",
    "c1Date": "SP",
    "EndToEndId1": "1234 1234",
    "fIn1Type": "BankRec",
    "fIn1Client": "Gherkin Test"
}

Thanks for some pointers on how to get the json data into the specflow feature file.

1
Please do not post images of code. Instead, edit your question to include them as plain text code blocks. - Greg Burghardt
ok, done. not as pretty though ;-) - rupweb
I cleaned it up a little bit. You can have a look at the markdown to see how I enabled syntax highlighting. There is a help icon in the question editor with more information. - Greg Burghardt

1 Answers

0
votes

The SpecFlow.ExternalData plugin is currently limited to a single parameter.
Please upvote the feature request at https://support.specflow.org/hc/en-us/community/posts/360015106078-Allow-multiple-parameters-to-be-used-with-External-Data-plugin to get this higher in our backlog priority.