What are the steps required to use NUnit?

I developed a small application in C #. I want to test my application using NUnit. I am new to NUnit.I Installed NUnit, but I don’t know how to use it, what basic steps it needs or please provide me with a link to the link about using NUnit.

+4
source share
3 answers

I recommend that you have your own project for your tests (e.g. Project.Tests ).

Put the following base files somewhere in the folder of your project structure (e.g. lib\nunit\nunit ):

  • nunit.core.dll
  • nunit.core.interfaces.dll
  • nunit.framework.dll
  • nunit.util.dll
  • nunit-console.exe
  • nunit-console.exe.config
  • nunit-console-runner.dll
  • nunit-console-x86.exe
  • nunit-console-x86.exe.config

Then you need to reference the NUnit.Framework assembly in your Project.Tests project.

For example, a simple test would look like this:

 using NUnit.Framework; namespace Project.Tests { [TestFixture] public class MyTestClass { [Test] public void MyTestMethod() { var a = "a"; var b = "a"; Assert.AreEqual(a, b); } } } 

You can run this test, for example, using NUnit-console or directly in VisualStudio (for example, using ReSharper ) or using the MSBuild task using the MSBuild Community Tasks .

+2
source

Note the quick start of NUnit :

Let's start with a simple example. Suppose we are writing an application bank, and we have a base class domain - Account. Account support operations for deposit, withdrawal and transfer of funds.

+3
source

If you do not use resharper, I recommend that you use this plugin - http://www.testdriven.net/ .

0
source

Source: https://habr.com/ru/post/1338647/


All Articles