-
Notifications
You must be signed in to change notification settings - Fork 0
Step argument transformations
If you want to keep it really short you can use the step transformations that comes with Reqnroll.Assist.Dynamic. A step argument transformation can simplest be described as a way to get typed object for a certain pattern in a Given/When/Then-attribute - see the Reqnroll feature that describes how Step Argument Transformation are used (https://docs.reqnroll.net/latest/automation/step-argument-conversions.html)
In Reqnroll.Assist.Dynamic three transformations comes out of the box; from Reqnroll Table to dynamic instance, from Reqnroll Table to List and transformation from Reqnroll Table to IEnumerable.
To use these add the following to your app.config-file (under the -node):
<stepAssemblies>
<stepAssembly assembly="Reqnroll.Assist.Dynamic" />
</stepAssemblies>
That configuration is added by default with the NuGet installation script.
Using this step arguments transformation is then as easy as:
Scenario:
Scenario: Test property with step argrument transformation
Given I create a dynamic instance from this table using step argument transformation
| Name | Age | Birth date | Length in meters |
| Marcus | 39 | 1972-10-09 | 1.96 |
Then the Name property should equal 'Marcus'
Step definitions:
private dynamic _instance;
[Given(@"I create a dynamic instance from this table using step argument transformation")]
public void c(dynamic instance)
{
_instance = instance;
}
[Then(@"the Name property should equal '(.*)'")]
public void NameShouldBe(string expectedValue)
{
((string)_instance.Name).Should().Equal(expectedValue);
}