Native ApprovalTests for C++
The Approvaltests library helps you write ApprovalTests, which are unit tests for complex objects that most people think can't be tested.
ApprovalTests are also known as Golden Master Tests.
Here is an intro to learn more about the concept of ApprovalTesting.
ApprovalTests are great for testing objects with lots of fields, or lists of objects.
Currently working in Mac/Linux/Windows with
The video Quickly Testing Legacy Code gives an introduction both to Approval Tests and to this library. The slides from the talk are available in PowerPoint and PDF formats. Sample code from the talk is available on Github.
I highly suggest you clone The Approval.cpp Starter Project
You need to include 2 lines for your main file to work.
For catch (1 and 2), it's these two lines:
// main.cpp: #define APPROVALS_CATCH // This tells Approval Tests to provide a main() - only do this in one cpp file #include "ApprovalTests.hpp"
For Google Test, it's these:
// main.cpp: #define APPROVALS_GOOGLETEST // This tells Approval Tests to provide a main() - only do this in one cpp file #include "ApprovalTests.hpp"
For all other test files, you need:
ApprovalTests uses ApprovalTests to test ApprovalTests (it's turtles all the way down).
Checkout our own tests to see how we do it.
ToString (ostream insertion)
Often, you will need to create functions to allow objects to print their state. This is commonly done with on ostream
You can find examples here: To String
Feedback: If you have any comment or suggestion on this documentation, please email me at: firstname.lastname@example.org