userver: userver/utils/statistics/testing.hpp File Reference
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
testing.hpp File Reference

Your opinion will help to improve our service

Leave a feedback >

Detailed Description

Utilities for analyzing emitted metrics in unit tests.

Definition in file testing.hpp.

Go to the source code of this file.

#include <iosfwd>
#include <optional>
#include <stdexcept>
#include <string>
#include <vector>
#include <userver/utils/not_null.hpp>
#include <userver/utils/statistics/labels.hpp>
#include <userver/utils/statistics/metric_value.hpp>
#include <userver/utils/statistics/storage.hpp>
+ This graph shows which files directly or indirectly include this file:

Classes

class  utils::statistics::MetricQueryError
 Thrown by statistics::Snapshot queries on unexpected metrics states. More...
 
class  utils::statistics::Snapshot
 A snapshot of metrics from utils::statistics::Storage. More...
 

Namespaces

namespace  utils
 Utilities.
 

Functions

void utils::statistics::PrintTo (const Snapshot &data, std::ostream *)
 Support for gtest diagnostics for utils::statistics::Snapshot.
 
void utils::statistics::PrintTo (MetricValue value, std::ostream *)
 Support for gtest diagnostics for utils::statistics::MetricValue.
 

Function Documentation

◆ PrintTo()

void utils::statistics::PrintTo ( const Snapshot & data,
std::ostream *  )

Support for gtest diagnostics for utils::statistics::Snapshot.

Warning
Never check the printed value programmatically! The string is not stable and may change, depending on the version of stdlib and userver.

Valid usage:

EXPECT_EQ(..., ...) << testing::PrintToString(snapshot);

Invalid usage:

std::ostringstream stream;
PrintTo(snapshot, &stream);
EXPECT_EQ(stream.str(), ...);