Anyone have any ideas about this one? My google searches are turning up nothing at all.
I'm tasked with performing two changes to our company's code base:
- Convert all tests which used to use MSTest/VStest to NUnit.
- Convert all tests which used to use NUnit 2.x to NUnit 3.x.
Converting VSTest->Nunit is mostly just search and replace, with maybe a little hand tweaking.
NUnit 2.x->3.x is quite tricky because of the fuckton of
breaking changes involved that I have to work around, which aren't just plain old search-and-replace operations. So far, the trickiest change I see is that Nunit 3.x has removed the [ExpectedException] attribute in favor of testing Assert.Throws( ()-> ...
Does anyone have a link to any resources which might have scripts or programs to help with the conversion? Here's an example of the kind of conversion I need to do:
ORIGINAL:
[Test]
[ExpectedException(typeof(MyCompany.Diagnostics.AssertionFailedException), ExpectedMessage = "action should not be null.", MatchType = MessageMatch.Contains)]
public void ExecuteWithNullAction()
{
new CancellationManager(this.Token).Execute(null);
}
REPLACEMENT:
[Test]
public void ExecuteWithNullAction()
{
Assert.That(() => new CancellationManager(this.Token).Execute(null),
Throws.Exception
.TypeOf<MyCompany.Diagnostics.AssertionFailedException>()
.With.Property("Message")
.StringContaining("action should not be null.")
);
}
And it's not even always that simple. Maybe the call to the code under test is buried among dozens of lines. Since there are hundreds of such instances in our code base already, it's a bit too daunting to do each one by hand.
Any ideas what would make this easier?