Igloo is a unit testing framework for C++ that aims to:

  • stay out of your way and let you focus on what you want to test
  • help you create readable tests
  • have a syntax that doesn’t make you repeat yourself

License

Igloo is distributed under the Boost Software License, Version 1.0, which encourages both commercial and non-commercial use.

Example

The following listing shows a complete test application written in Igloo:

#include <igloo/igloo.h>
using namespace igloo;

Context(a_guitar_with_a_fuzzbox)
{
  void SetUp()
  {
    guitar.AddEffect(fuzzbox);
  }

  Spec(fuzzbox_starts_in_clean_mode)
  {
    Assert::That(guitar.Sound(), Equals(Clean));
  }

  Context(a_fuzzbox_in_distorted_mode)
  {
    void SetUp()
    {
      Parent().fuzzbox.Switch();
    }

    Spec(when_I_fret_the_strings_the_sound_is_distorted)
    {
      Assert::That(Parent().guitar.Sound(), Equals(Distorted));
    }

    Spec(when_I_switch_the_fuzzbox_the_sound_is_clean)
    {
      Parent().fuzzbox.Switch();
      Assert::That(Parent().guitar.Sound(), Equals(Clean));
    }
  };

  Fuzzbox fuzzbox;
  Guitar guitar;
};

int main()
{
  return TestRunner::RunAllTests();
}

Screencast

The following video shows Igloo being used as the testing framework to create one possible solution to the Conway’s Game of Life TDD Kata.

In this example we use the alternative Describe/It syntax instead of the original Context/Spec syntax. If you want to use the alternative syntax you should #include <igloo/igloo_alt.h> instead of #include <igloo/igloo.h>. The alternative syntax is available from version 0.6.

C++ TDD Kata: Conway’s Game of Life from Joakim Karlsson on Vimeo.

Installing Igloo

Igloo is implemented as a set of header files. Therefore there is no need for you to go through any additional steps to build it. After you’ve downloaded Igloo, just tell your build system to look for additional header files in the directory where you put Igloo, and you’re ready to go.