Skip to main content

Unit testing best practices

Introduction

Summary

Unit testing is a great way to validate that a small unit code of meets its design and behaves as expected. A unit of code can be a class, a method, a static function or a portion of these.

In order to write reliable unit tests, programmers must take into consideration the characteristics of a good unit test and follow unit testing best practices. This tutorial the most common best practices when it comes to writing unit tests.

Examples in this tutorial are given in Java/Junit, but the principles can be applied to most programming languages and unit test frameworks.

Prerequisites

  • Practical understanding of unit tests in Java or another programming language.