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 while still looking like normal C++
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:
Note that we have replaced the old TestFixture/TestMethod terminology with support for nested Contexts and Specs. We still support the old terminology to ensure compatibility with the previous version.
#include <igloo/igloo.h>
using namespace igloo;
Context(AGuitarWithAFuzzbox)
{
void SetUp()
{
guitar.AddEffect(fuzzbox);
}
Spec(FuzzboxStartsInCleanMode)
{
Assert::That(guitar.Sound(), Equals(Clean));
}
Context(FuzzboxIsInDistortedMode)
{
void SetUp()
{
Parent().fuzzbox.Switch();
}
Spec(WhenIFretTheStringsTheSoundIsDistorted)
{
Assert::That(Parent().guitar.Sound(), Equals(Distorted));
}
Spec(WhenISwitchTheFuzzboxTheSoundIsClean)
{
Parent().fuzzbox.Switch();
Assert::That(Parent().guitar.Sound(), Equals(Clean));
}
};
Fuzzbox fuzzbox;
Guitar guitar;
};
int main()
{
return TestRunner::RunAllTests();
}
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.