userver: utest::LogCaptureFixture< Base > Class Template Reference
Loading...
Searching...
No Matches
utest::LogCaptureFixture< Base > Class Template Reference

#include <userver/utest/log_capture_fixture.hpp>

Detailed Description

template<typename Base = ::testing::Test>
class utest::LogCaptureFixture< Base >

Fixture that allows to capture and extract log written into the default logger.

using GrpcCancelSleep = utest::LogCaptureFixture<
UTEST_F(GrpcCancelSleep, CancelByTimeoutLogging) {
call_options.SetTimeout(std::chrono::milliseconds(500));
UEXPECT_THROW(GetClient().SayHello({}, std::move(call_options)), ugrpc::client::DeadlineExceededError);
// Make sure server logs are written.
GetServer().StopServing();
// Check logs via utest::LogCaptureFixture :
EXPECT_THAT(GetLogCapture().Filter("", {{"error_msg", "Call is interrupted"}}), testing::SizeIs(1))
<< GetLogCapture().GetAll();
}
See also
utest::LogCaptureLogger

Definition at line 144 of file log_capture_fixture.hpp.

+ Inheritance diagram for utest::LogCaptureFixture< Base >:

Static Public Member Functions

static void TearDownTestSuite ()
 

Protected Member Functions

LogCaptureLoggerGetLogCapture ()
 
void SetDefaultLogger (logging::LoggerPtr new_logger)
 
void SetDefaultLoggerLevel (logging::Level new_level)
 Set the default logger level.
 

Constructor & Destructor Documentation

◆ LogCaptureFixture()

template<typename Base = ::testing::Test>
utest::LogCaptureFixture< Base >::LogCaptureFixture ( )
inlineprotected

Definition at line 146 of file log_capture_fixture.hpp.

Member Function Documentation

◆ GetLogCapture()

template<typename Base = ::testing::Test>
LogCaptureLogger & utest::LogCaptureFixture< Base >::GetLogCapture ( )
inlineprotected
Returns
logger that holds the log records of the unit test

Definition at line 149 of file log_capture_fixture.hpp.

◆ SetDefaultLogger()

void utest::DefaultLoggerFixture< ::testing::Test >::SetDefaultLogger ( logging::LoggerPtr new_logger)
inlineprotectedinherited

Set the default logger and postpone its destruction till the coroutine engine stops

Definition at line 32 of file default_logger_fixture.hpp.

◆ SetDefaultLoggerLevel()

void utest::DefaultLoggerFixture< ::testing::Test >::SetDefaultLoggerLevel ( logging::Level new_level)
inlineprotectedinherited

Set the default logger level.

Definition at line 43 of file default_logger_fixture.hpp.

◆ TearDownTestSuite()

static void utest::DefaultLoggerFixture< ::testing::Test >::TearDownTestSuite ( )
inlinestaticinherited

Definition at line 24 of file default_logger_fixture.hpp.


The documentation for this class was generated from the following file: