mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-07 06:39:55 +01:00
e92b9c07c3
Unlike the relatively non-invasive old way of capturing stdout/stderr, this new way is also able to capture output from C's stdlib functions such as `printf`. This is done by redirecting stdout and stderr file descriptors to a file, and then reading this file back. This approach has two sizeable drawbacks: 1) Performance, obviously. Previously an installed capture made the program run faster (as long as it was then discarded), because a call to `std::cout` did not result in text output to the console. This new capture method in fact forces disk IO. While it is likely that any modern OS will keep this file in memory-cache and might never actually issue the IO to the backing storage, it is still a possibility and calls to the file system are not free. 2) Nonportability. While POSIX is usually assumed portable, and this implementation relies only on a very common parts of it, it is no longer standard C++ (or just plain C) and thus might not be available on some obscure platforms. Different C libs might also implement the relevant functions in a less-than-useful ways (e.g. MS's `tmpfile` generates a temp file inside system folder, so it will not work without elevated privileges and thus is useless). These two drawbacks mean that, at least for now, the new capture is opt-in. To opt-in, `CATCH_CONFIG_EXPERIMENTAL_REDIRECT` needs to be defined in the implementation file. Closes #1243 |
||
---|---|---|
.. | ||
assertions.md | ||
build-systems.md | ||
command-line.md | ||
commercial-users.md | ||
configuration.md | ||
contributing.md | ||
event-listeners.md | ||
limitations.md | ||
list-of-examples.md | ||
logging.md | ||
matchers.md | ||
opensource-users.md | ||
own-main.md | ||
Readme.md | ||
release-notes.md | ||
release-process.md | ||
reporters.md | ||
slow-compiles.md | ||
test-cases-and-sections.md | ||
test-fixtures.md | ||
tostring.md | ||
tutorial.md | ||
why-catch.md |
Reference
To get the most out of Catch2, start with the tutorial. Once you're up and running consider the following reference material.
Writing tests:
- Assertion macros
- Matchers
- Logging macros
- Test cases and sections
- Test fixtures
- Reporters
- Event Listeners
Fine tuning:
Running:
FAQ:
Other: