1. Downloaded Nunit from link
2. Created a Test Project in VS 2008
3. Add Reference to DLL nunit.framework.dll in the project
4. Copy below modifed code in UnitTest1.cs
public class TestDesign
{
public int SumofTwoNumbers(int InputA, int InputB)
{
return (InputA + InputB);
}
}
namespace APITest
{
using NUnit.Framework;
[TestFixture]
public class TestExample
{
[Test]
//Test Method
public void TestAddAPI()
{
TestDesign TD = new TestDesign();
Assert.AreEqual(30,TD.SumofTwoNumbers(10, 20));
Assert.AreEqual(33, TD.SumofTwoNumbers(10, 23));
}
//Data Driven Testing
[TestCase(10, 10, Result=20)]
[TestCase(15, 15, Result=30)]
[TestCase(20, 20, Result=40)]
public int TestAddAPI(int a, int b)
{
TestDesign TD = new TestDesign();
return TD.SumofTwoNumbers(a, b);
}
}
}
5. Build the Project6. Using Nunit Open the Debug folder, You will see Test Project DLL. Below is the snapshot of results
More Reads - Nunit Quick Start
A Test Harness with WatiN, TestDriven.NET, NUnit with Visual Studio 2008 (Team System)
Getting started with NUnit and BizUnit
Automated Testing with Selenium 2 and NUnit
Happy Reading!!
No comments:
Post a Comment