Pattern: Test Bomb

Intent

To safely disable a test, which can't be fixed right now for some reasons.

Also Known As

Time Bomb

Motivation

Sometimes perfectly good test starts to fail and for some reasons fixing the test right now is not feasible or possible. This can happen because: developer team is under tremendous time pressure and does not have time to investigate test depends on some external infrastructure that is expected to be down test fails because of refactoring in progress and it is not clear how to best fix it yet.

Most team pick one of two options:

Test Bomb provides a better alternative.

Applicability

Use Test Bomb when there's a failing test, but it can't be fixed right now.

Description

Instead of permanently disabling a test, disable it temporary, so that it starts failing again after some time. This might require special tool support or code changes.

Example

// AccountManagerTest.java

public void testAccountManager() {
    if (TestUtils.bomb(1, 9, 2012)) return; //bomb till 1 sepetmber 2012

    //some account manager testing code goes here 
}


// TestUtils.java

public static void bomb(int day, int month, int year) {
  if (DateUtil.isInThePast(day, month, year)) return false;
  return true;
}