Skip to content

Latest commit

 

History

History
90 lines (66 loc) · 3.74 KB

File metadata and controls

90 lines (66 loc) · 3.74 KB

Troubleshooting

Contents

Test gives "You have forgotten to configure your test framework..."

Root Cause:

A problem in your test program's main() means that ApprovalTests.cpp is not correctly set up for your test framework.

Symptom

Running tests gives the following output:

************************************************************************************
*                                                                                  *
* Welcome to Approval Tests.
*
* You have forgotten to configure your test framework for Approval Tests.
*
* To do this in Catch, add the following to your main.cpp:
*
*     #define APPROVALS_CATCH
*     #include "ApprovalTests.hpp"
*
* To do this in Google Test, add the following to your main.cpp:
*
*     #define APPROVALS_GOOGLETEST
*     #include "ApprovalTests.hpp"
*
* To do this in doctest, add the following to your main.cpp:
*
*     #define APPROVALS_DOCTEST
*     #include "ApprovalTests.hpp"
*
* For more information, please visit:
* https://github.com/approvals/ApprovalTests.cpp/blob/master/doc/GettingStarted.md
*                                                                                  *
************************************************************************************

snippet source / anchor

Things to check:

  • Have you created a main.cpp that sets up ApprovalTests?
    • If not, the default Google Test main() will be used, which will not set up Approval Tests
    • To fix, copy in the non-comment code from tests/GoogleTest_Tests/main.cpp
  • Is your main.cpp included in your project's build?
    • If not, the default Google Test main() will be used, which will not set up Approval Tests
    • To fix, e.g. check your CMakeLists.txt file
  • Does your Google Test have its own custom main.cpp?
  • Is your code calling Approvals::verify() or any other methods in this library from outside a Google Test?
    • This is much less likely to be the cause, but the file-naming code in Approval Tests (ApprovalTestNamer) does require that approvals are used from inside a test method in a supported test framework.

My custom reporter works in development, but not CI

Check your test code - especially your main - for any uses of Approvals::useAsFrontLoadedReporter() that are specific to running on a Continuous Integration system.

If that's the case, and you do still want to use a custom reporter in an individual test, you can use Approvals::useAsFrontLoadedReporter() in the test, passing in your custom reporter, to take precedence over the CI-specific reporter in your main.


Back to User Guide