mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-23 03:43:28 +01:00
parent
3dcc923351
commit
1ea84cb734
@ -1,6 +1,32 @@
|
|||||||
# Logging macros
|
# Logging macros
|
||||||
|
|
||||||
Additional messages can be logged during a test case.
|
Additional messages can be logged during a test case. Note that the messages are scoped and thus will not be reported if failure occurs in scope preceding the message declaration. An example:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
TEST_CASE("Foo") {
|
||||||
|
INFO("Test case start");
|
||||||
|
for (int i = 0; i < 2; ++i) {
|
||||||
|
INFO("The number is " << i);
|
||||||
|
CHECK(i == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Bar") {
|
||||||
|
INFO("Test case start");
|
||||||
|
for (int i = 0; i < 2; ++i) {
|
||||||
|
INFO("The number is " << i);
|
||||||
|
CHECK(i == i);
|
||||||
|
}
|
||||||
|
CHECK(false);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
When the `CHECK` fails in the "Foo" test case, then two messages will be printed.
|
||||||
|
```
|
||||||
|
Test case start
|
||||||
|
The number is 1
|
||||||
|
```
|
||||||
|
When the last `CHECK` fails in the "Bar" test case, then only one message will be printed: `Test case start`.
|
||||||
|
|
||||||
|
|
||||||
## Streaming macros
|
## Streaming macros
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user