Start unit testing in C++ with Isolator++!
Isolator++ enables easy unit testing of existing and new C++ code.
Unit testing in C++ is a hassle. But once you've decided to do it, you're faced with the main problem of unit testing in any language - you can't unit test the code, because it depends on classes and external resources. Without tests, the code is vulnerable to regression bugs, and therefore you usually don't touch it, and are scared just from the thought.
Isolator++ allows you change the behavior of dependencies in your code, without changing it. You build a test application using the framework of your choice (GoogleTest, UnitTest++, CppUnit, etc.), include Isolator++ header file, link with the Isolator++ library and then use the Isolator++ APIs in your tests to change the behavior of method calls to dependencies. All this without changing their code. Isolator++ contains innovative features to keep your tests short, readable and robust.
The method has a dependency on the time when the code is run. How can we test the result for a year after 2017?
With Isolator++'s macros (in red), you can simply change the behavior of the localtime method:
When the IsExpired method is called, the call to localtime is ignored, and then returns the value we supply - our future time construct.
Without changing the code, we actually we able to simulate the localtime to check a second path in the code.
To learn more about how to use Isolator++, check out the next chapters:
Copyright © Typemock Ltd. 2009-2019. All Rights Reserved.