I Developed a small Application in C#. I want to test my application with NUnit.I am a new to NUnit.I Installed NUnit but don't Know How to use it what are the basic steps needed for it or please provide me a good ref开发者_运维问答erence link about using NUnit.
Check out the NUnit quick start:
Let’s start with a simple example. Suppose we are writing a bank application and we have a basic domain class – Account. Account supports operations to deposit, withdraw, and transfer funds.
I recommend you to have an own project for your tests (like Project.Tests
).
Place the following basic files somewhere in 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 then for example with the NUnit-console or directly in VisualStudio (e.g. with the help of ReSharper) or through a MSBuild task with the help of MSBuild Community Tasks.
If you don't use resharper I recommend you to use this plugin - http://www.testdriven.net/ .
精彩评论