yiabiten
yiabiten

Reputation: 810

Configure cultureInfo for Specflow

I have two machines with different cultures where the format mm/dd/yyyy is successfully parsed by Specflow (it's a step argument) in one but fails in the other.

I want my tests to be culture independent. So how to configure Specflow to use CultureInfo.InvariantCulture for parsing dates ?

Upvotes: 6

Views: 1427

Answers (3)

howardcrick
howardcrick

Reputation: 27

The above answer by Ted is not quite correct and would not work for me. You need to set binding culture in your specflow.json file for .net by doing the following:

{
    "bindingCulture": {
        "name": "en-US"
    }
}

Upvotes: 0

Ted
Ted

Reputation: 755

For those looking for a .NET Core answer, you need to add a specflow.json file, set to Copy always or Copy if newer, to your project.

{
  "bindingCulture": "en-US"
}

Upvotes: 1

yiabiten
yiabiten

Reputation: 810

Well, as nobody answered this. My solution for the problem was to edit the App.config file and add <bindingCulture name="en-US" /> in the <specflow> config section.

This forces Specflow, on both machines, to correctly parse MM/dd/yyyy date format.

Upvotes: 8

Related Questions