Tutorials and resources on how to apply unit testing in software testing
In this article, Andrew Hunter shares his opinion that unit tests and test driven development (TDD) now dominate the types of test that are used in software development. This situation has limited the attention available for other software testing types, such as the integration tests. Thus he asks the question: “Are unit tests overused?“
This article by Lasse Koskela, provides several tips on how to improve the speed of your Java unit tests. The strategy to improve the speed up test code is to find slow things and either make them run faster or not run them at all.
In this blog post, Nicolas Frankel explains how to perform unit testing on a database using DBUnit, Spring and TestNG. DbUnit is a JUnit extension for database-driven projects that, among other things, puts your database into a known state between test runs. This is an excellent tool to avoid the issues that can occur when one test case corrupts the database and causes subsequent tests to fail. DbUnit has also the ability to export and import your database data to and from XML datasets.
In this article, Brett Schuchert discusses how modern mocking tools affects positively our ability to work with legacy code and the possible negative implications of using mocking tools. These tools allow us to perform unit testing without actually changing the underlying code. He starts with a discussion about the challenges of unit testing and how mocking tools help to solve them; at least on the surface.
PHPUnit is a unit testing software framework for PHP. It provides both a framework that makes writing unit tests easy as well as the functionality to easily run the tests and analyze their results. This video shows you how to build a relatively simple class, using TDD techniques. It also discusses various PHPUnit methods and explains how to create mock objects.
This article explains how Microsoft Fakes perform a similar role than mocking in unit testing, helping you to isolate the code you are testing in Visual Studio by replacing other parts of the application with stubs or shims. A stub replaces another class with a small substitute that implements the same interface. A shim modifies the compiled code of your application at run time so that instead of making a specified method call, it runs the shim code that your test provides.
Andrew Hunt and David Thomas have produced a nice Unit Testing Cheat Sheet (PDF document) based on the unit testing principles introduced in their book Pragmatic Unit Testing in Java. This document contains the Right-BICEP hint to determine what to test, the A-TRIP acronym that help remembering the properties of good tests and the CORRECT approach to assess boundary conditions in software testing.