Ich benutze specflow
, um meine Browser-Tests schreiben mit Gherkin
Syntax. Ich habe eine Schrittdefinition, in der ich zwei verschiedene Schritte zusammenführen, aber nicht erfassen möchte. Für zB:Regex Spiel in Gurke, aber nicht erfassen
Scenario:
Given I have some stuff
And I click on the configure user
And I configure user
And I set the user <config> to <value>
Then I should see user configuration is updated
Scenario:
Given I have some stuff
And I click on the configure admin
And I configure admin
And I set the admin <config> to <value>
Then I should see user configuration is updated
Der Schritt Definition regex für And I set the admin <config> to <value>
wäre so etwas wie:
Given(@"And I set the admin (.*) to (.*)")
public void AndISetTheAdminConfigToValue(string config, string value)
{
// implementation
}
Und für And I set the user <config> to <value>
wäre wie:
Given(@"And I set the admin (.*) to (.*)")
public void AndISetTheUserConfigToValue(string config, string value)
{
// implementation
}
Die Umsetzung der beiden Stufen gleich sind. Also, was ich möchte, ist tun:
Given(@"And I set the user|admin (.*) to (.*)")
public void AndISetTheConfigToValue(string config, string value)
{
// implementation
}
Der obige Code wird nicht funktionieren wie config
und value
Parameter leere Zeichenkette wird als user
und admin
als ersten 2 Parameter erfasst werden.
Gibt es eine Möglichkeit, etwas wie oben zu tun, ohne die Regex-Übereinstimmungen im Parameter zu erfassen?
Ich weiß, dass ich das Szenario einfach umschreiben kann, um wie folgt das Problem zu lösen. Aber ich bin nur neugierig.
Scenario:
Given I have some stuff
And I click on the configure admin
And I configure admin
And I set the <config> to <value>
Then I should see user configuration is updated
Das Umschreiben des Szenarios nicht übereinstimmen sieht aus wie das ursprüngliche Szenario gleich. Hat die Abschriftenformatierung einige Zeichen entfernt? –