Reqnroll matches more generic StepArgumentTransformation than Specflow
Used Visual Studio
Visual Studio 2022
Are the latest Visual Studio updates installed?
Yes
Content of reqnroll.json (if present)
No response
Issue Description
I don't know whether this is a bug or a new feature, but we're upgrading our project from Specflow to Reqnroll and have te following issue. Take the following code snippet:
[Binding]
public class Transforms
{
[StepArgumentTransformation]
public IEnumerable<Book> BooksTransform(DataTable booksTable)
{
// some code
return // some IEnumerable<Book>
}
[StepArgumentTransformation]
public DataTable Transform(DataTable table)
{
// some code
return // some Table
}
}
The first method is more specific for the return type, the second one is generic for a DataTable. (In Specflow this is the Table class)
Having a step like
[StepDefinition(...)]
public async Task PerformStep(IEnumerable<Book> books)
{
//
}
then in Specflow, only the first transformation wil be selected and run. However, with Reqnroll, both transformations will be selected and run. Probably because a DataTable is also an IEnumerable<T>? Is this a bug? And when not, is there a workaround?
Steps to Reproduce
Upgrade this code to Reqnroll:
[Binding]
public class Transforms
{
[StepArgumentTransformation]
public IEnumerable<Book> BooksTransform(Table booksTable)
{
// some code
return // some IEnumerable<Book>
}
[StepArgumentTransformation]
public Table Transform(Table table)
{
return // some Table
}
}
From Table to DataTable
[Binding]
public class Transforms
{
[StepArgumentTransformation]
public IEnumerable<Book> BooksTransform(DataTable booksTable)
{
// some code
return // some IEnumerable<Book>
}
[StepArgumentTransformation]
public DataTable Transform(DataTable table)
{
return // some DataTable
}
}
In Specflow, only the first transformation will run when the StepDefinition with an IEnumerable<Book> as parameter is run, in reqnroll both will run
Link to a project repository that reproduces the issue
No response
This is at the wrong project. Transferring...
I don't really know what the expected behaviour should be.
But I know there is a Order attribute, see https://docs.reqnroll.net/latest/automation/step-argument-conversions.html#step-argument-transformation So I would say it should match both?
Yes, @304NotModified has a good point. I did not even remember this order thing.
@wilfriedb Could you please try what happens if you add an order to it, like:
[Binding]
public class Transforms
{
[StepArgumentTransformation(Order = 1)]
public IEnumerable<Book> BooksTransform(DataTable booksTable)
{
// some code
return // some IEnumerable<Book>
}
[StepArgumentTransformation(Order = 2)]
public DataTable Transform(DataTable table)
{
return // some DataTable
}
}
Is the issue specific to DataTable or does it also happen when you use Table?