From 50bc113bcba408688fa760e467cdddeaf0fcf537 Mon Sep 17 00:00:00 2001 From: eric846 <56563761+eric846@users.noreply.github.com> Date: Mon, 14 Sep 2020 15:32:01 -0400 Subject: [PATCH] add comments to mock classes Signed-off-by: eric846 <56563761+eric846@users.noreply.github.com> --- .../adaptive_load/mock_metrics_evaluator.h | 14 ++++++++++++ .../mock_session_spec_proto_helper.h | 22 +++++++++++++++++++ .../common/mock_nighthawk_service_client.h | 13 +++++++++++ 3 files changed, 49 insertions(+) diff --git a/test/mocks/adaptive_load/mock_metrics_evaluator.h b/test/mocks/adaptive_load/mock_metrics_evaluator.h index fe66a90ff..d7824eacd 100644 --- a/test/mocks/adaptive_load/mock_metrics_evaluator.h +++ b/test/mocks/adaptive_load/mock_metrics_evaluator.h @@ -6,8 +6,22 @@ namespace Nighthawk { +/** + * A mock MetricsEvaluator that returns empty values from all methods. + * + * Typical usage: + * + * MockMetricsEvaluator mock_metrics_evaluator; + * BenchmarkResult benchmark_result; + * // (set benchmark_result fields here) + * EXPECT_CALL(mock_metrics_evaluator, AnalyzeNighthawkBenchmark(_, _, _)) + * .WillRepeatedly(Return(benchmark_result)); + */ class MockMetricsEvaluator : public MetricsEvaluator { public: + /** + * Empty constructor. + */ MockMetricsEvaluator(); MOCK_CONST_METHOD3(EvaluateMetric, diff --git a/test/mocks/adaptive_load/mock_session_spec_proto_helper.h b/test/mocks/adaptive_load/mock_session_spec_proto_helper.h index 9503b4d32..49dda391a 100644 --- a/test/mocks/adaptive_load/mock_session_spec_proto_helper.h +++ b/test/mocks/adaptive_load/mock_session_spec_proto_helper.h @@ -6,8 +6,30 @@ namespace Nighthawk { +/** + * A mock AdaptiveLoadSessionSpecProtoHelper that returns empty values or success from all methods + * by default. + * + * In particular, SetSessionSpecDefaults does not pass its input value through to its output; + * regardless of the output, it returns an empty proto, unless explicitly configured (see below). If + * you don't need to inspect calls to the spec proto helper, it may be easier to use the real + * AdaptiveLoadSessionSpecProtoHelperImpl in tests instead. + * + * Typical usage: + * + * NiceMock mock_spec_proto_helper; + * EXPECT_CALL(mock_spec_proto_helper, CheckSessionSpec(_)) + * .WillOnce(Return(absl::OkStatus())); + * AdaptiveLoadSessionSpec spec; + * // Set spec fields here, including providing all defaults yourself. + * EXPECT_CALL(mock_spec_proto_helper, SetSessionSpecDefaults(_)) + * .WillOnce(Return(spec)); + */ class MockAdaptiveLoadSessionSpecProtoHelper : public AdaptiveLoadSessionSpecProtoHelper { public: + /** + * Empty constructor. + */ MockAdaptiveLoadSessionSpecProtoHelper(); MOCK_CONST_METHOD1(SetSessionSpecDefaults, diff --git a/test/mocks/common/mock_nighthawk_service_client.h b/test/mocks/common/mock_nighthawk_service_client.h index 7d527805e..66e3bdb46 100644 --- a/test/mocks/common/mock_nighthawk_service_client.h +++ b/test/mocks/common/mock_nighthawk_service_client.h @@ -6,8 +6,21 @@ namespace Nighthawk { +/** + * A mock NighthawkServiceClient that returns an empty response by default. + * + * Typical usage: + * + * NiceMock mock_nighthawk_service_client; + * nighthawk::client::ExecutionResponse nighthawk_response; + * EXPECT_CALL(mock_nighthawk_service_client, PerformNighthawkBenchmark(_, _)) + * .WillRepeatedly(Return(nighthawk_response)); + */ class MockNighthawkServiceClient : public NighthawkServiceClient { public: + /** + * Empty constructor. + */ MockNighthawkServiceClient(); MOCK_CONST_METHOD2(PerformNighthawkBenchmark,