Introducing Unit Testing

Unit Testing

After writing the code every programmer does some kind of testing to make sure this-that of his/her code is working as expected or not. This testing is called Unit Testing.

Unit testing is done in different ways. Some programmers write simple test applications to test their own code. Whereas, some others simply debug the code and change the values during debugging to make sure that that the code works fine for different cases of concerns.

Some facts about unit testing:-

  1. Unit Testing is done by developers
  2. Quality department does different tests, and are not considered as unit tests
  3. Every programmer must do unit testing after finishing the development or during the development itself
  4. Unit testing can be done by writing separate test applications to call your classes and methods to make sure the classes work as expected. This is called unit testing
  5. Unit testing can be automated by writing unit test scripts. This is called Automated Unit Testing
  6. In the automated Unit Testing, after writing classes or methods we will write several test methods to test the actual code. The test method will call your actual classes or methods with some sample inouts and compare the result with the expected result. If the actual result, from your code, is the same as the expected result, the Unit Test will record the result as "Success". Otherwise the test result will be recorded as "Fail". All of the unit test scripts can be executed together and you can get a summary of all the results
  7. Automated Unit test scripts can be saved and easily repeated so that every time someone makes a change in the project, hundreds of automated unit tests can be executed in a mere few seconds to make sure that every piece of code is still working as expected
  8. NUnit is one of the most popular automated unit testing tool for .NET applications

Automated unit tests can be done without using any unit testing tool like NUnit. However, unit test frameworks like NUnit makes the job very easy.

This blog targets the absolute beginners and gives a short review about Testing.

Hopefully this will help you explore more.

Thank you!!

Ebook Download
View all
Learn
View all