Skip to content
Native ApprovalTests for C++ on Linux, Mac and Windows
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ApprovalTests
ApprovalTests_Catch1_Tests
ApprovalTests_Catch2_Tests
ApprovalTests_GoogleTest_Tests
build
doc
examples
lib
.gitattributes
.gitignore
.travis.yml
BUILD-Windows.md
BUILD-Windows.source.md
CMakeLists.txt
CMakeLists.txt.in
CODEOWNERS
LICENSE
README.md
README.source.md
appveyor.yml
fix_markdown.sed
fix_markdown.sh
run_markdown_templates.sh
to_do.txt

README.md

CppApprovals

Contents

Introduction

Build Status

Build status

License

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.

Intro Graphic

Currently working in Mac/Linux/Windows with

Getting Started

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.

See Getting Started and the evolving User Guide.

I highly suggest you clone The Approval.cpp Starter Project

Main File

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"

snippet source

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"

snippet source

For all other test files, you need:

#include "ApprovalTests.hpp"

Examples

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 << operator. You can find examples here: To String

Suggested Examples

Feedback: If you have any comment or suggestion on this documentation, please email me at: llewellyn.falco@gmail.com

You can’t perform that action at this time.