Introduction to Unit Tests

Unit testing is a software testing method by which individual units of source code, together with associated control data, usage procedures, and operating procedures, are tested to determine whether they are fit for use.

A unit is the smallest testable part of an application. In procedural programming, a unit could be an entire module, or an individual function or procedure. In object-oriented programming, a unit is often a class, but could be an individual method. (source = Wikipedia).

 

Some of the properties of good unit tests are:

  1. Unit tests should be fully isolated. They should run independently of other tests.

  2. When it fail, it should give proper indication of what has failed and what was the expectation.

  3. Unit test should only test a single unit at a time. There should not be any real dependency.

  4. It should continue to run consistently always as long as the functionality of the unit has not changed.

  5. Unit tests should be faster and easier to run. There should not be need to configure any machine or create a setup for running tests.

  6. Unit testing is usually automated and is usually done using an unit testing framework.

 

Popular unit testing frameworks or helper libraries in Java

  1. JUnit

  2. TestNG

  3. DBUnit

  4. Spring Test

  5. Mockito 

Tags: 

Contact

We learn together, do innovations and then document them.

Offline Contact
We connect physically only in Bengaluru currently, but most of our activities happen online. Please follow us here or in social media for more details.
WhatsApp (Primary): (+91) 7411174113
WhatsApp (Secondary): (+91) 7411174114

Business newsletter

Complete the form below, and we'll send you an e-mail every now and again with all the latest news.

About Cloudericks

Team Cloudericks is a community to learn about and master cloud computing. Current learning focus is on AWS cloud.

We believe that knowledge is useless unless you share it; the more you share, the more you learn. Visit Cloudericks.

Recent comments

Photo Stream