Skip to content

TestCaseSource: "Too many arguments provided" for IEnumerable<> parameter type #1792

@ChrisMaddock

Description

@ChrisMaddock

@debugosaurus commented on Wed Sep 14 2016

It appears that NUnit has started treating Array and Enumerable TestCaseSource parameters differently. I noticed this behaviour when upgrading from 3.0 to 3.4.1.0 (sorry that covers a lot of ground).

Say I declare some test data:

protected static IEnumerable<IEnumerable<string>> EnumerableOfStrings => new[] 
{ 
    new[] { "one", "two" }
};

The following test will pass:

[Test, TestCaseSource(nameof(EnumerableOfStrings))]
public void AcceptsArrayOfStrings(string[] array)
{
}

However this test will fail with the message "Too many arguments provided":

[Test, TestCaseSource(nameof(EnumerableOfStrings))]
public void AcceptsEnumerableOfStrings(IEnumerable<string> enumerable)
{
}

It seems with the second test that NUnit is attempting to unbox the enumerable and pass each element as an argument rather than passing the enumerable as a single parameter.


@ChrisMaddock commented on Wed Sep 14 2016

I can reproduce this - agreed it seems to be a bug. (Great bug report, by the way! 👍)

I'll also move this issue over to the NUnit framework repo - this ones just for doc issues. 😄

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions