Access:

» Unit Testing Using Test Driven Development (TDD)

Related categories: High quality and secure programming | TDD | Unit Testing

Joanna Nowakowska, Lucjan Stapp
Viewed: 9631 | Article date: 2006-01-19 11:27:40

Test Driven Development (TDD) solves many problems between developers and testers which concern unit testing. In this article the authors will show that code development following the TDD methodology is neither expensive nor time-consuming and greatly improves quality of the final product. They will begin by presenting a basic concepts of TDD, after which we will describe a simple experiment demonstrating the achieved effects. We will also present an example collection of tools facilitating preparation of modules adhering to this methodology.

 

Joanna Nowakowska is Quality Assurance Consultant at Rodan Systems S.A, where among her other tasks she is responsible for methodology of conducting unit tests. The first person in Poland who received the ISTQB Certified Tester Full Advanced Level certificate in March 2005. Co-founder of SJSI, a member of German Testing Board.

Contact with the author: j.nowakowska@sjsi.org

 

Lucjan Stapp, PhD in mathematical sciences, is academic staff member of Warsaw University of Technology. He worked as a leader of project and quality assurance teams. An advocate of light-weight methodologies, also in testing. Co-founder of SJSI, chairman of the SJSI Revision Committee.

Contact with the author: l.stapp@sjsi.org

 

 

 

Research conducted in the field shows that about 80 % of all errors made while developing software are bugs in code of particular components (the main source of bugs in software is project documentation - usually because of its imprecision, incompleteness, inconsistency, frequently-made changes etc.; here on the other hand we're talking about mistakes made directly in the software). As a consequence, their detection and correction should greatly affect the quality of the system being developed. As the same time, the cost of fixing a bug strongly depends on the moment the bug has been found. According to Barry Boehm, removal of a bug found during unit testing can cost up to several hundred times less than removal of the same bug after the software has already been shipped to the customer.

Therefore, conduction of unit (component) tests greatly influences the quality of developed software. The main goal of conducting such tests is to dynamic, now-level verification of systems under tests (from hereafter referred to as SUT) at an early stage of course of a project. Having defined components of SUT such as modules, classes and their methods, one should verify correct operation of each of those components separately (in isolation) from the rest of the application.

 

TDD, Unit Testing

Figure 1. The V model

 

What unit tests give us:

  • they enable us to unambiguously pinpoint the occurrence of a bug, as well as to point out inefficient lines of program code at the level of separate modules,

  • they prevent shadowing of bugs in one component with operation of another component,

  • by operating directly on the code of systems, they grant access to vital information about the quality and coverage of tests at the lowest possible cost of all kinds of tests.

What is more, the classic V model (see Figure 1.) implies unit testing is the first stage of dynamic testing for developed software. In many organisations this leads to a conflict between the development and the testing teams regarding who should be responsible for preparation and execution of unit tests. On one hand, arguments exist for handing these tasks over to a programmer, as:

  • he/she knows best the code of a certain system component,

  • changes to code can lead to side effects which are easy to spot for the author of that code but much harder for a third party (who naturally doesn't know the code as well as its author).

On the other hand, programmers do not want to test their own code because they think that:

  • they have got no time for testing - the schedule gives no room for anything beyond development of new code,

  • tests are boring and pointless,

  • programmers do not make mistakes,

  • they lack competence with respect to testing,

  • the SUT will be tested by the testing team anyway.

Advocates of soft methodologies know a solution to this problem - namely, the methodology called Test Driven Development (TDD in short). Its application facilitates solving problems between the developers and the testers that concern uni testing. Nevertheless, it causes reluctance in many environments, including project and development team leaders, as there are always misgivings that its application would generate certain - high, possibly - additional cost and increase the time required to create code, with mediocre or no final effect. In this article we will show that code development following the TDD methodology is neither expensive nor time-consuming and greatly improves quality of the final product. In order to be well-understood we will begin by presenting the basic concepts of TDD, after which we will describe a simple experiment demonstrating the achieved effects. We will also present an example collection of tools facilitating preparation of modules adhering to this methodology.

Page: 1 2 3
Buy article Buy subscription
Buy now add to cart
add to cart
Standard price: 2€/$3 Standard price: 25€/$30
Buy article for as little as (2€/$3) each allow access to individual articles. Buy a full access to our Software Developers's Journal archive portal. You will be able to read the articles from all archive issues from year 2005 and 2006. For just 25€/$30 you get unrestricted access to the entire website for the whole year.
SDJhakin9

.SDJ Users:


.:Login
.:Password

[Register]
[Forgotten your password?]

...Shopping Cart

sum: 0 €
Choose currency:

...Topics

...Advertisement

www.acunetix.com www.verifysoft.com

...Conferences




...Print Edition Archive

...Affiliate Program



 

 

Subscribe | Contact Us | Newsletter | Privacy policy | Regulations | See all issues | About SDJ
Copyright C 2006 by Software Developer's Journal. All rights reserved.