I am writing a unit test in xUnit that receives few fixed parameters, plus a variable number of extra parameters. The signature of the test would be like the one below. From the ellipsis onwards, the test can have from none up to 20 parameters more.
public async void MyTest(string ID, string count, string sid, string token, string domain, string expectedOutcome, ...)
I can't make it work using the params keyword, and according to this link, that won't be possible in a near future.
Moreover, PropertyData and ClassData properties allow to parameterise the test with a variable number of parameters, but if I would take this approach, I would have to move all the fixed parameters to the code related to these properties, and that's not an option because most tests won't even use the extra parameters.
I have also tried to change the signature to the following...
public async void MyTest(string ID, string count, string sid, string token, string domain, string expectedOutcome, List<string> parameters)
... But when I build, I get an error in the lines of code where I initialise the list inside the InlineData properties:
An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
Is there an elegant way of doing this? So far I have hard-coded several sets as class variables, corresponding to these extra parameters. But I have to manually change the set to be used within the unit test code, before each run. Since I am still developing, this is not a problem at the moment, but it will be when I will have to deploy the tests.