Skip to content

Latest commit

 

History

History
76 lines (51 loc) · 2.28 KB

File metadata and controls

76 lines (51 loc) · 2.28 KB

Getting Started - Creating your main()

Contents

Introduction

This page shows how to set up the main() for test programs that use Approval Tests.

These steps are needed in order to teach Approval Tests how to name its output files automatically.

If, after following these steps, you need help with running your program, please see Troubleshooting.

Main File

The Basics

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 / anchor

For all other test files, you need:

#include "ApprovalTests.hpp"

Details

Choosing a testing framework

If you are already using one of the above testing frameworks, that is the one you should use.

If not, Approval Tests works well with all the above. Here are factors to consider.

Framework Ease of setup IDE Integration Compile and link time
Catch Very easy (single-header). StarterProject Widely supported Not bad - has options to speed up
doctest Very easy (single-header) Unknown Fast
Google Test Difficult Very widely supported Fast

Back to User Guide