You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the above example, the expression will be I enter the name (Jill Smith) and I would like to turn the String "Jill Smith" from the capture group into the type Person in my step definition.
I note that you can do this when using native Swift based feature steps as shown in your README by resolving the Person instance into JSON via the description property.
Given("User is loggeed in as \(Person(name:"Nick"))")
I assume what happens here is Person(name: "Nick") is encoded into JSON so the expression becomes: "User is logged in as ({"name": "Nick"}))" and then when the test is run it encodes that back into the Person type?
I assume in my situation I would have to write the feature file like:
Scenario Outline: My test outlineGiven I enter the name {"name": "<name>"}
Examples:
| name | | JillSmith |
But this is less than ideal.
Is there another way I achieve this? Thanks.
The text was updated successfully, but these errors were encountered:
@cameroncooke yes, in swift tests json string is encoded as part of the step expression and then decoded from this string. It might work if you write json structure in a feature file if you implement step so that it uses Codable parameter, but this was not tested specifically (we can add tests for that if it really works).
I think more proper solution though would be to support data tables - I had it working for swift tests, don't remember if I did anything for feature files, but I'll need to find time to get back to this.
This is simplistic example but proves my point.
Given I have a feature file like:
and the step definition:
and the model:
In the above example, the expression will be
I enter the name (Jill Smith)
and I would like to turn the String "Jill Smith" from the capture group into the typePerson
in my step definition.I note that you can do this when using native Swift based feature steps as shown in your README by resolving the
Person
instance into JSON via the description property.I assume what happens here is
Person(name: "Nick")
is encoded into JSON so the expression becomes:"User is logged in as ({"name": "Nick"}))"
and then when the test is run it encodes that back into thePerson
type?I assume in my situation I would have to write the feature file like:
But this is less than ideal.
Is there another way I achieve this? Thanks.
The text was updated successfully, but these errors were encountered: