Pass array of string to xunit test method

Use params before the method’s string[] argument, and then you won’t need to initialize a string[] in InlineData attribute, rather you could use a variable number of string literals, for which the compiler doesn’t complain one bit:

[Theory]
    [InlineData("2000-01-02", "2000-02-01")]
    public void TestSynchronizeMissionStaffing_PeriodNoMatch(params string[] dateStrings)

Leave a Comment