GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ApprovalTests.cpp/doc/GettingStarted.md at master · approvals/ApprovalTests.cpp

Expand file tree

/

GettingStarted.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
76 lines (54 loc) · 3.13 KB
/

GettingStarted.md

Copy path

File metadata and controls

76 lines (54 loc) · 3.13 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

Getting Started - Creating your main()

Contents

  • Introduction
  • Main File
    • The Basics
    • Details
  • Choosing a testing framework

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 Catch2, 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

  • Using Approval Tests With Catch
  • Using Approval Tests With CppUTest
  • Using Approval Tests With Google Tests
  • Using Approval Tests With Doctest
  • Using Approval Tests With Boost.Test
  • Using Approval Tests With [Boost].UT

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 Min C++ Ease of setup IDE Support Build time
Catch2 C++11 Very easy [1], [2] Widely supported Not bad [3]
CppUTest C++11 Difficult Unknown Very Fast
doctest C++11 Very easy [1] Unknown Fast
Google Test C++11 Difficult Very widely supported Fast
Boost.Test C++11 Difficult Unknown Fast
[Boost].UT C++20 [4] Very easy [1] Unknown Fast
  1. Released as a single header file
  2. See the Starter Project
  3. Catch2 has options to speed up its builds
  4. [Boost].UT works with C++17, but the ApprovalTests interface to that library depends on std::source_location, which is a C++ 20 feature.

Back to User Guide

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.