Here is an example test for our customer library written in GTest:
#include "customer/customer.h"
#include <gtest/gtest.h>
TEST(basic_responses, given_name_when_prepare_responses_then_greets_friendly) {
auto name = "Bob";
auto code_and_string = responder{}.prepare_response(name);
ASSERT_EQ(code_and_string.first, web::http::status_codes::OK);
ASSERT_EQ(code_and_string.second, web::json::value("Hello, Bob!"));
}
Most of the tasks that are commonly done during testing have been abstracted. We're mostly focused on providing the action we want to test (prepare_response) and the desired behavior (both ASSERT_EQ lines).