How can I run NUnit tests in Visual Studio 2017?

Add the NUnit test adapter NuGet package to your test projects 2.* (https://www.nuget.org/packages/NUnitTestAdapter/) 3.* (https://www.nuget.org/packages/NUnit3TestAdapter/) Or install the Test Adapter Visual Studio extension. There is one for 2.* (https://marketplace.visualstudio.com/items?itemName=NUnitDevelopers.NUnitTestAdapter) 3.* (https://marketplace.visualstudio.com/items?itemName=NUnitDevelopers.NUnit3TestAdapter). I prefer the NuGet package, because it will be in sync with the NUnit version used by your project and will thus automatically match the … Read more

NUnit vs. Visual Studio 2008’s test projects for unit testing [closed]

Daok named all the pro’s of Visual Studio 2008 test projects. Here are the pro’s of NUnit. NUnit has a mocking framework. NUnit can be run outside of the IDE. This can be useful if you want to run tests on a non-Microsoft build server, like CruiseControl.NET. NUnit has more versions coming out than visual studio. You … Read more

How do I use Assert.Throws to assert the type of the exception?

Assert.Throws returns the exception that’s thrown which lets you assert on the exception. var ex = Assert.Throws<Exception>(() => user.MakeUserActive()); Assert.That(ex.Message, Is.EqualTo(“Actual exception message”)); So if no exception is thrown, or an exception of the wrong type is thrown, the first Assert.Throws assertion will fail. However if an exception of the correct type is thrown then … Read more

Different return values the first and second time with Moq

With the latest version of Moq(4.2.1312.1622), you can setup a sequence of events using SetupSequence. Here’s an example: _mockClient.SetupSequence(m => m.Connect(It.IsAny<String>(), It.IsAny<int>(), It.IsAny<int>())) .Throws(new SocketException()) .Throws(new SocketException()) .Returns(true) .Throws(new SocketException()) .Returns(true); Calling connect will only be successful on the third and fifth attempt otherwise an exception will be thrown. So for your example it would … Read more

NUnit vs. MbUnit vs. MSTest vs. xUnit.net [closed]

I know this is an old thread, but I thought I’d post a vote for xUnit.NET. While most of the other testing frameworks mentioned are all pretty much the same, xUnit.NET has taken a pretty unique, modern, and flexible approach to unit testing. It changes terminology, so you no longer define TestFixtures and Tests…you specify … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)