Belle II Software light-2406-ragdoll
|
Test fixture to be able to check the contents and types of emitted log messages in detail. More...
#include <Fixtures.h>
Protected Member Functions | |
void | SetUp () override |
Add a log message interceptor. | |
void | TearDown () override |
And try to reset logging system to default. | |
void | expectMessage (LogConfig::ELogLevel level=LogConfig::c_Error, int count=1, bool strict=false) |
check if there is a certain number of log messages of a given level | |
void | expectMessageContent (LogConfig::ELogLevel level, const std::string &message) |
check the content of the last log message against the given values | |
void | expectMessageVariables (std::map< std::string, std::string > &&variables, bool strict=false) |
check if the last message emitted contains the given variables and their values. | |
void | expectErrorWithVariables (std::map< std::string, std::string > &&variables, bool strict=false) |
Expect an error with variables: This is a shorthand to check that there is exactly one error message present and that it contains the given variables. | |
void | clearMessages () |
clear the list of save log messages | |
Protected Attributes | |
std::vector< LogMessage > | m_messages |
list of log messages | |
Test fixture to be able to check the contents and types of emitted log messages in detail.
In contrast to EXPECT_B2ERROR() and others defined here this test fixture will keep a copy of every message emitted and all messages can be expected in detail. There are a few convenient members to check for message counts and message contents.
Definition at line 23 of file Fixtures.h.
|
inlineprotected |
clear the list of save log messages
Definition at line 62 of file Fixtures.h.
|
protected |
Expect an error with variables: This is a shorthand to check that there is exactly one error message present and that it contains the given variables.
This also clears the list of messages for convenience so after each call which is supposed to create an error this function can be called to handle the error message and afterwards the list of messages will be clean again for the next test.
This is a shorthand to just call expectMessage(), expectMessageVariables() and clearMessages()
variables | map of name->value mapping for all expected variables |
strict | if true also fail the test if there's any other variable in the message |
Definition at line 75 of file Fixtures.cc.
|
protected |
check if there is a certain number of log messages of a given level
level | which log level to check for |
count | how many message should be expected |
strict | if true don't allow any other messages: the total number of messages must be equal to count and all need to have severity level |
Definition at line 47 of file Fixtures.cc.
|
protected |
check the content of the last log message against the given values
level | log level we expect for the message |
message | expected string content of the message. |
Definition at line 82 of file Fixtures.cc.
|
protected |
check if the last message emitted contains the given variables and their values.
variables | map of name->value mapping for all expected variables |
strict | if true also fail the test if there's any other variable in the message |
Definition at line 59 of file Fixtures.cc.
|
overrideprotected |
Add a log message interceptor.
Definition at line 33 of file Fixtures.cc.
|
overrideprotected |
And try to reset logging system to default.
Definition at line 42 of file Fixtures.cc.
|
protected |
list of log messages
Definition at line 26 of file Fixtures.h.