Unit Testing Succinctly: Testing Basics

This is an extract from the Unit Testing Succinctly eBook, by Marc Clifton, kindly provided by Syncfusion.

First, it is assumed that two other vital pieces of any software development project are in place:

  • A source control system, such as CVS, SVN, Git, Mercurial, etc.
  • A bug tracking system, such as Bugzilla, FogBugz, etc.

Microsoft provides integration of these pieces with Visual Source Safe, SharePoint, and other products.

If you do not have both of these pieces already in place, stop now. These are vital components of a good solid unit testing process.


So You Have a Bug

If you discover a bug, either through using the application or a failed unit test:

  • Report the bug in the bug tracker and assign it to someone.

If the bug is not reported by a unit test but was discovered through using the code (either another developer or a user):

  • Write the unit test that verifies how to create the issue (see “negative testing” described earlier).

With your source control system:

  • Consider creating a branch specifically for this bug fix.

Then:

  • Write the unit test that describes how the method should correctly behave.
  • Fix the bug and retest.

With your source control system:

  • Check in the changes, referring to the bug number assigned by the bug tracker.
  • If you added new unit tests, check these in, again referring to the bug number.
  • If you branched the code, decide when you want to merge the changes into the main branch.

Tracking and Reporting

By working with a bug-tracking and version-control system, anyone (from manager to junior programmer) can easily review:

  • The changes made to the code base.
  • The unit tests to create the problem.
  • The unit tests that fix the problem.

This makes life a lot easier for the developer team, the management, and even the end-user if your project is set up such that the end-user is interested in this level of detail. (For example, if software is developed in-house for another department, others might be interested in knowing when a bug is fixed.)

Integration with other technologies such as SharePoint can facilitate the communication between team members, managers, and other departments. Also, using sophisticated source control tools such as Perforce and continuous integration tools such as CruiseControl.NET will further integrate and automate the use of source control with unit testing, integration testing, reporting tools, and so forth.

Tags:

Comments

Related Articles