7

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

6 Answers 6

4

There are many fine examples on NUnit's developer wiki.

Update as the original link is broken:

Basic examples can be found on the NUnit Documentation Page. Check out the Getting Started/QuickStart subsection, and the Assertions/* subsection.

Sign up to request clarification or add additional context in comments.

1 Comment

Dead links make this choice not so helpful.
3

From my own projects (real life, so not just demos where everything will be nice and simple :)

Both are reasonably small, and although MiscUtil is the bigger of the two, it's mostly a collection of very small, individual components.

MoreLINQ is heavily tested; MiscUtil has patchier coverage as I started it before getting into unit testing.

Comments

1

You should find NUnit samples in with the download of NUnit; these are very good examples of how to use NUnit.

Comments

1

I don't think reading unit tests helps as much as seeing someone writing them and explaining why they are doing the way they are. try some screencasts. DimeCast.Net for example....

Comments

1

This should be useful...

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

Comments

0

I would recommend to watch video on TDD at dnrTV. See Part 1 and Part 2.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.