NUnit example code?

I would like to learn how to use NUnit. I learn better by reading, and then play with real code. Where can I find a small, simple C # project that uses NUnit in an exemplary way?

+6
c # unit-testing nunit
source share
6 answers

There are many great examples on the NUnit developer wiki .

Update as the original link is broken :

Basic examples can be found on the NUnit documentation page . Check the “Getting Started / Quick Start” section and the “Approvals / *” subsection.

+4
source share

From my own projects (real life, so not just a demo where everything will be fine and simple :)

Both are small enough, and although MiscUtil is the larger of the two, it is basically a collection of very small individual components.

MoreLINQ is heavily tested; MiscUtil has a denser coating when I started it before entering into unit testing.

+3
source share

You should find NUnit samples with NUnit download; these are very good examples of using NUnit.

+1
source share

I don't think that reading module tests helps in the same way as seeing someone write them and explaining why they do the way they are. try some screencasts. DimeCast.Net, for example ....

+1
source share

This should be helpful ...

using System.Text; using NUnit.Framework; namespace Test.SampleTests { [TestFixture] public class CustomerTestClass { [TestCase(1, true)] // valid customer [TestCase(2, true)] // valid customer [TestCase(1123123123132, false)] // invlaid customer public void IsValidCustomerTest(int customerId, bool isValid) { Assert.AreEqual(_service.ValidateCust(customerId), isValid); } } } 

Taken from here - https://coderwall.com/p/vwvura

+1
source share

I would recommend watching a video on TDD on dnrTV. See Part 1 and Part 2 .

0
source share

All Articles