Skip to main content

Posts

Showing posts from May, 2018

Demo Project (NUnit Setup)

Steps-->  1.Create a new project in console application. 2.Write the production code in a separate class file.I have written a regular calculator that can do addition, substraction, multiplication, division operation. 3.Add a new class library for test purpose. 4.Add a   reference to our production code from our test project. 5.Install NUnit3Test Adapter Tools->Extensions and Updates->Online->NUnit3 Test Adpter 6.Install NUnit Reference->Manage Nuget Packages->Online->Nunit Now we can use NUnit’s attributes and NUnit asserts. 7.Under class library file write the test code using NUnit attributes. [TestFixture] public class RegularCalcultorTests { RegularCalculator calculator; [SetUp] public void BeforeEachTest () { calculator = new RegularCalculator(); } [Test] public void TestAddition () { var result=

Getting started NUnit

  NUnit is a open source framework.We can write automated tests to test our .Net code using the NUnit framework. NUnit does not create any test scripts by itself. We have to write test scripts by ourselves, but NUnit allows us to use its tools and classes to make unit testing easier. Automated test à 1.Find defects earlier in development lifecycle thus reduced business cost. 2.Makes user happy as fewer defect reach in production environment. 3.Development team get more time to add new feature. 4.Reliable as same test code runs each time 5.Quicker   than a human performing tests manually Features of NUnit à 1.Tests can be run from a console runner, within Visual Studio through a Test Adapter. The console runner works through the NUnit Test Engine, which provides it with the ability to load, explore and execute tests. 2.Tests can be run in parallel. 3.Follows strongly TDD 4.Assertion tell the test runner whether test has passed and failed Attributes of