Everyone responds to new requirements on already-behind-schedule projects in a different way.  Many people feel anger, and try to find an innocuous way to show it.  Others, realizing this might finally be their chance to shine, take it as a challenge with a smile.  Still others, like Gary's colleague Steve, find a way to fulfill the requirements without actually fulfilling the requirements.

With less than a week remaining till the deadline of a 4-month-long project, Gary and Steve's boss demanded everyone write Unit test code.  Gary spent hour upon unpaid overtime hour adding as many unit tests as he could come up with, while Steve left by 5pm each day.  Their boss also asked them to set up a nightly script to perform the unit tests automatically.  Each night Steve's test set would always come back with 100% successful results.

A few weeks after launch, Gary asked Steve how he managed to build so many unit tests in such a short amount of time.

Steve responded, "Oh, I read a book on unit testing months ago, and it really prepared me to write tests in no time at all."

Still not convinced how Steve managed to achieve this goal so easily, Gary opened up one of Steve's unit test files only to discover this:

  public class TransactionProcessorTest {
      private boolean state = false;
      public void init() {
          state = true;
      }

      @Test
      public void testInit() {
         
TransactionProcessorTest = new TransactionProcessorTest();
          Assert.assertEquals(false, t.state);
          t.init();
          Assert.assertEquals(true, t.state);
      }
  }

Gary realized the code had indeed tested something, that Steve knew nothing about unit testing.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!