You Can't Be Agile without Automated Unit Testing


Agile projects assume that test planning, test creation, and test execution take place throughout a project's lifecycle. So the need for unit testing (and especially automated unit testing) can't be ignored and should be considered as a key responsibility of the entire team—not just the software developers.

Agile methodologies are approaches to managing software development based  on  short-term, iterative,  and  incremental  deliveries,  enabling   continuous feedback and flexible response to change.

Stemming  from  a  rapidly  evolving  business  environment that  demands  faster product improvements and modifications, the agile methodology promotes  the organizational qualities of speed,  responsiveness,  and  adaptability throughout the  entire application management process, from defining product requirements to coding, testing, and, finally, release management.

This article  explains  why agile development cannot  be implemented  effectively without unit  testing—and especially automated unit testing.

The Importance of Code Quality

Developers have known for decades that the further into a project  timeline a bug gets discovered  from its insertion  point, the more costly it is to fix. When a developer finds a bug, it can sometimes  take  minutes  to  fix. If it slips through testing  and finds its way  to  the  customer,  figure 1 shows  that  mitigation can be exponentially more expensive to fix. [1]

Correcting  quality issues can take months of rework, cost millions  of dollars,  or,  if done  too  late,  may  even cost  lives. Take,  for  example,  the  first launch  of the  Ariane  5 rocket  in 1996.  Its flight abruptly terminated just  thirty-seven  seconds after  liftoff,  taking  with  it hundreds of millions  of dollars  in invested effort. Also think of Toyota recalling four hundred thousand vehicles because of a bug in the brake control  system, costing an estimated  three billion dollars.

While  we  can’t  eliminate  all  bugs,  we  can  fight  them  by baking  quality  into  the  code.  There  are  many  ways to  define code quality  depending  on the perspective  of the customer  or the developer.

The  customer   expects   working   software.   Customers   do not  care how the code is written—they just need the software to  work.  When  developers  talk  about  code quality,  they  talk about  code that  is easy to maintain, easy to read, and risk-adverse to change. Each perspective takes the cost of bugs into consideration. The  customer  knows  that  for  each  bug,  he’ll lose precious business hours or days. The developer knows that each returning bug means considerable time spent fixing it in- stead of working  on new features.

Agile methodologies take working  software  and combine  it with early feedback. For example, early releases can get user feedback about  how well the software  operates.  To give the developers  confidence that  their code works,  unit testing gives the fastest available quality feedback.

The  earlier  defects are  found,  the  cheaper  they  are  to  fix. As agile methodologies encourage  high code quality,  the team should run lots of unit tests. Similarly, automated tests give the developer early feedback on the quality of the software in a repeatable fashion prior to release.

What Is Unit Testing?

Unit testing is a methodology where individual units of software,  associated  data,  and  usage procedures are tested  to determine  whether  they  operate  correctly.  The  unit  is usually  a small piece of code—for  example,  a single function.  The unit test is a short  function  that  tests the behavior  of the unit  that produces  a pass/fail  result.  This is achieved by performing the tested  function  on a known  value with  a single correct  result. Unit tests often use mock objects to simulate the behavior of dependencies  in a predictable way.

The main  purpose  of unit  testing  is to allow  developers  to identify as many problems  as possible at the development stage and  to do it in an automated, repeatable fashion  that  can be applied for every code change.

This makes developers directly responsible for producing working   code,  even  before  it  reaches  the  quality   assurance team.
Article3 Image1

User Comments

1 comment

About the author

Upcoming Events

Feb 20
Apr 29
Jun 03
Jun 25