Debian Codegraph @

3rdparty/catch2/docs/faq.md

raw symbols SCIP
1 <a id="top"></a>
2 # Frequently Asked Questions (FAQ)
3
4 **Contents**<br>
5 [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>
6 [How do I clean up global state between running different tests?](#how-do-i-clean-up-global-state-between-running-different-tests)<br>
7 [Why cannot I derive from the built-in reporters?](#why-cannot-i-derive-from-the-built-in-reporters)<br>
8 [What is Catch2's ABI stability policy?](#what-is-catch2s-abi-stability-policy)<br>
9 [What is Catch2's API stability policy?](#what-is-catch2s-api-stability-policy)<br>
10 [Does Catch2 support running tests in parallel?](#does-catch2-support-running-tests-in-parallel)<br>
11 [Can I compile Catch2 into a dynamic library?](#can-i-compile-catch2-into-a-dynamic-library)<br>
12 [What repeatability guarantees does Catch2 provide?](#what-repeatability-guarantees-does-catch2-provide)<br>
13
14
15 ## How do I run global setup/teardown only if tests will be run?
16
17 Write a custom [event listener](event-listeners.md#top) and place the
18 global setup/teardown code into the `testRun*` events.
19
20
21 ## How do I clean up global state between running different tests?
22
23 Write a custom [event listener](event-listeners.md#top) and place the
24 cleanup code into either `testCase*` or `testCasePartial*` events,
25 depending on how often the cleanup needs to happen.
26
27
28 ## Why cannot I derive from the built-in reporters?
29
30 They are not made to be overridden, in that we do not attempt to maintain
31 a consistent internal state if a member function is overridden, and by
32 forbidding users from using them as a base class, we can refactor them
33 as needed later.
34
35
36 ## What is Catch2's ABI stability policy?
37
38 Catch2 provides no ABI stability guarantees whatsoever. Catch2 provides
39 rich C++ interface, and trying to freeze its ABI would take a lot of
40 pointless work.
41
42 Catch2 is not designed to be distributed as dynamic library, and you
43 should really be able to compile everything with the same compiler binary.
44
45
46 ## What is Catch2's API stability policy?
47
48 Catch2 follows [semver](https://semver.org/) to the best of our ability.
49 This means that we will not knowingly make backwards-incompatible changes
50 without incrementing the major version number.
51
52
53 ## Does Catch2 support running tests in parallel?
54
55 Not natively, no. We see running tests in parallel as the job of an
56 external test runner, that can also run them in separate processes,
57 support test execution timeouts and so on.
58
59 However, Catch2 provides some tools that make the job of external test
60 runners easier. [See the relevant section in our page on best
61 practices](usage-tips.md#parallel-tests).
62
63
64 ## Can I compile Catch2 into a dynamic library?
65
66 Yes, Catch2 supports the [standard CMake `BUILD_SHARED_LIBS`
67 option](https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html).
68 However, the dynamic library support is provided as-is. Catch2 does not
69 provide API export annotations, and so you can only use it as a dynamic
70 library on platforms that default to public visibility, or with tooling
71 support to force export Catch2's API.
72
73
74 ## What repeatability guarantees does Catch2 provide?
75
76 There are two places where it is meaningful to talk about Catch2's
77 repeatability guarantees without taking into account user-provided
78 code. First one is in the test case shuffling, and the second one is
79 the output from random generators.
80
81 Test case shuffling is repeatable across different platforms since v2.12.0,
82 and it is also generally repeatable across versions, but we might break
83 it from time to time. E.g. we broke repeatability with previous versions
84 in v2.13.4 so that test cases with similar names are shuffled better.
85
86 Random generators currently rely on platform's stdlib, specifically
87 the distributions from `<random>`. We thus provide no extra guarantee
88 above what your platform does. **Important: `<random>`'s distributions
89 are not specified to be repeatable across different platforms.**
90
91
92 ---
93
94 [Home](Readme.md#top)