Category Archives: Unit Testing

Dummy, Fake, Stub, and Mock

Mock is a generic term that covers a family of stand-in objects for use in unit testing. Dummy: Dummy objects are simple mocks. Generally dummy objects are stands for an external resource. When a method is invoked they usually return a predefined response for a method. They usually can’t vary the response based on input… Read More »

Mocking the objects

During writing software we always try to limit the dependencies. Therefore in order to form a greater whole our components must be coupled each other. These couplings create dependencies within the application. Application can be also dependent on some external resources like database, web service, file system or other resources. During writing unit test for… Read More »

An Introduction to NUnit Framework

Most unit tests are writing by following a very simple pattern as follows: +. Perform some activity to set up your test. +. Execute your test. +. Verify its result. +. If necessary, reset your environment. Test methods must reside into a class. This class is known as TestFixture class. In order to make a… Read More »

Others types of Tests

So far we’re discussed about unit testing and also shown an example of Unit Testing. But unit testing is not only tests that are important to software development. By unit test we only checks that classes, methods and services meet the business requirements and provide the necessary functionality. A complete application has many more dimensions… Read More »

Quick Example of TDD using NUnit

Following example develop a feature for system using TDD. The feature will count occurrences of a character in a string. @. Now create a solution and named it FirstTDDExample. @. Add new Class Library project and name it “FirstTDDExample” @. Also add another Class Library project and name it “FirstTDDExample.Test” @. Go to View ->… Read More »

Test driven Development

According to Wikipedia: Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: first the developer writes an (initially failing) automated test case that defines a desired improvement or new function, then produces the minimum amount of code to pass that test, and finally refactors the… Read More »

Test First Development

Test first development is a development style where write unit tests before writing the production code. Simple steps of Test First Development: Simple steps for Test First Developments are +. Write the specification +. Write the tests to the specification +. Write the code until the entire test passes We can simplify above steps as… Read More »

Unit Testing Frameworks

There are a rich collection of unit testing framework exists. In Wikipedia we can see their unit testing frameworks listed for just about any language or platform.There are a rich collection of unit testing framework exists. In Wikipedia we can see their unit testing frameworks listed for just about any language or platform. For details… Read More »

Unit Testing New Code vs. Existing Code

Testing the Greenfield code is far easier than testing the Brownfield code or legacy code. The main reason is that during the code of Brownfield application or legacy code we don’t consider about testability. So the class structure in the systems is often more tightly coupled than those codes that developed with tests. But it… Read More »

Unit Testing

Unit Test: A unit test is a test that designed confirms the functionality of a small unit of work in a large system i.e. check the functionality of a method of that held inside a class and ensures that the method behaves as expected. Note: A unit test usually tests ONE specific requirement for ONE… Read More »