2021-11-19 15:23:50 +01:00
|
|
|
<a id="top"></a>
|
|
|
|
# Frequently Asked Questions (FAQ)
|
|
|
|
|
2022-04-25 18:58:50 +02:00
|
|
|
**Contents**<br>
|
|
|
|
[How do I run global setup/teardown only if tests will be run?](#how-do-i-run-global-setupteardown-only-if-tests-will-be-run)<br>
|
|
|
|
[How do I clean up global state between running different tests?](#how-do-i-clean-up-global-state-between-running-different-tests)<br>
|
|
|
|
[Why cannot I derive from the built-in reporters?](#why-cannot-i-derive-from-the-built-in-reporters)<br>
|
|
|
|
[What is Catch2's ABI stability policy?](#what-is-catch2s-abi-stability-policy)<br>
|
|
|
|
[What is Catch2's API stability policy?](#what-is-catch2s-api-stability-policy)<br>
|
2022-08-18 00:14:07 +02:00
|
|
|
[Does Catch2 support running tests in parallel?](#does-catch2-support-running-tests-in-parallel)<br>
|
2022-09-03 22:31:25 +02:00
|
|
|
[Can I compile Catch2 into a dynamic library?](#can-i-compile-catch2-into-a-dynamic-library)<br>
|
2022-11-16 11:21:00 +01:00
|
|
|
[What repeatability guarantees does Catch2 provide?](#what-repeatability-guarantees-does-catch2-provide)<br>
|
|
|
|
|
2022-04-25 18:58:50 +02:00
|
|
|
|
2021-11-19 15:23:50 +01:00
|
|
|
## How do I run global setup/teardown only if tests will be run?
|
|
|
|
|
|
|
|
Write a custom [event listener](event-listeners.md#top) and place the
|
|
|
|
global setup/teardown code into the `testRun*` events.
|
|
|
|
|
|
|
|
|
|
|
|
## How do I clean up global state between running different tests?
|
|
|
|
|
|
|
|
Write a custom [event listener](event-listeners.md#top) and place the
|
|
|
|
cleanup code into either `testCase*` or `testCasePartial*` events,
|
|
|
|
depending on how often the cleanup needs to happen.
|
|
|
|
|
|
|
|
|
|
|
|
## Why cannot I derive from the built-in reporters?
|
|
|
|
|
2022-09-09 16:00:39 +02:00
|
|
|
They are not made to be overridden, in that we do not attempt to maintain
|
2023-04-25 20:14:27 +02:00
|
|
|
a consistent internal state if a member function is overridden, and by
|
2021-11-19 15:23:50 +01:00
|
|
|
forbidding users from using them as a base class, we can refactor them
|
|
|
|
as needed later.
|
|
|
|
|
|
|
|
|
2022-04-25 18:58:50 +02:00
|
|
|
## What is Catch2's ABI stability policy?
|
|
|
|
|
|
|
|
Catch2 provides no ABI stability guarantees whatsoever. Catch2 provides
|
|
|
|
rich C++ interface, and trying to freeze its ABI would take a lot of
|
|
|
|
pointless work.
|
|
|
|
|
|
|
|
Catch2 is not designed to be distributed as dynamic library, and you
|
|
|
|
should really be able to compile everything with the same compiler binary.
|
|
|
|
|
|
|
|
|
|
|
|
## What is Catch2's API stability policy?
|
|
|
|
|
|
|
|
Catch2 follows [semver](https://semver.org/) to the best of our ability.
|
|
|
|
This means that we will not knowingly make backwards-incompatible changes
|
|
|
|
without incrementing the major version number.
|
|
|
|
|
|
|
|
|
2022-06-22 00:14:26 +02:00
|
|
|
## Does Catch2 support running tests in parallel?
|
|
|
|
|
|
|
|
Not natively, no. We see running tests in parallel as the job of an
|
|
|
|
external test runner, that can also run them in separate processes,
|
|
|
|
support test execution timeouts and so on.
|
|
|
|
|
|
|
|
However, Catch2 provides some tools that make the job of external test
|
|
|
|
runners easier. [See the relevant section in our page on best
|
|
|
|
practices](usage-tips.md#parallel-tests).
|
|
|
|
|
|
|
|
|
2022-09-03 22:31:25 +02:00
|
|
|
## Can I compile Catch2 into a dynamic library?
|
|
|
|
|
|
|
|
Yes, Catch2 supports the [standard CMake `BUILD_SHARED_LIBS`
|
|
|
|
option](https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html).
|
|
|
|
However, the dynamic library support is provided as-is. Catch2 does not
|
|
|
|
provide API export annotations, and so you can only use it as a dynamic
|
|
|
|
library on platforms that default to public visibility, or with tooling
|
|
|
|
support to force export Catch2's API.
|
|
|
|
|
|
|
|
|
2022-11-16 11:21:00 +01:00
|
|
|
## What repeatability guarantees does Catch2 provide?
|
|
|
|
|
|
|
|
There are two places where it is meaningful to talk about Catch2's
|
|
|
|
repeatability guarantees without taking into account user-provided
|
|
|
|
code. First one is in the test case shuffling, and the second one is
|
|
|
|
the output from random generators.
|
|
|
|
|
|
|
|
Test case shuffling is repeatable across different platforms since v2.12.0,
|
|
|
|
and it is also generally repeatable across versions, but we might break
|
|
|
|
it from time to time. E.g. we broke repeatability with previous versions
|
|
|
|
in v2.13.4 so that test cases with similar names are shuffled better.
|
|
|
|
|
|
|
|
Random generators currently rely on platform's stdlib, specifically
|
|
|
|
the distributions from `<random>`. We thus provide no extra guarantee
|
|
|
|
above what your platform does. **Important: `<random>`'s distributions
|
|
|
|
are not specified to be repeatable across different platforms.**
|
|
|
|
|
|
|
|
|
2021-11-19 15:23:50 +01:00
|
|
|
---
|
|
|
|
|
|
|
|
[Home](Readme.md#top)
|