Skip to content

Assert.DoesNotThrow() stopped working as it was previously #3315

Description

@carbon88

Some specs of environment first.
Windows 10 1809 build 17763.557
VS 2017 v15.9.12
.Net Framework Version: 4.7.03190
Test project is targeted for .Net Core 2.0.3
NUnit package version: 3.12.0 (latest for now)
NUnit3TestAdapter package version 3.12.0

Let's say we have an extension method like:

public static void Run<T>(this IEnumerable<T> sequence)     {
     foreach (var item in sequence);
}

and I used to use it like
Assert.DoesNotThrow(someEnumerable.Run)

because IDE (or resharper, whatever) suggests me use it instead of
Assert.DoesNotThrow(()=>someEnumerable.Run())

And everything was fine but then I had to update because another bug was fixed it started failing my tests with the exception
"System.ArgumentException : The actual value must be a parameterless delegate but was TestDelegate.
Parameter name: parameterName"

What is that? Do you even test the changes you make, guys?

Here is the test:

[Test]
public void NunitDoesNotThrowTest()
{
  TestDelegate fullform = () => Enumerable.Repeat(1, 10).Run(); // it is your TestDelegate. working
  TestDelegate shortForm = Enumerable.Repeat(1, 10).Run; // this is to. should be working because IT IS your TestDelegate (acording to VS) you want me to pass into DoesNotThrow() method!
  Assert.DoesNotThrow(() => Assert.DoesNotThrow(fullform));
  Assert.DoesNotThrow(() => Assert.DoesNotThrow(shortForm));
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions