Wednesday, November 11, 2009

How to test a very particular factory

@Test(expected=IllegalArgumentException.class)
public void makeBaby() {
  Family family = moz.getFamily();
  assertNotNull(family);
  assertEquals(2, family.getChildren().size());
  BabyFactory factory = family.getWife();
  assertNotNull(factory);
  Baby babygirl = factory.makeBabyGirl("Mila");
  assertNotNull(babygirl);
  family.addChild(babygirl);
  assertEquals(3, family.getChildren().size());

  boss.askForRaise(moz);
}

Probably you should also set a timeout for the test, which should complete in about 40 weeks ;-)

No comments: