aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/testing/gtest/gtest.h
blob: 4ef30c3adaf145e5097eaec614085d3073b3ae9b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once

#include <library/cpp/testing/gtest_extensions/gtest_extensions.h>

#include <gtest/gtest.h>
#include <gmock/gmock.h>

#include <optional>
#include <string_view>

/**
 * Bridge between GTest framework and Arcadia CI.
 */
namespace NGTest {
    /**
     * Get custom test parameter.
     *
     * You can pass custom parameters to your test using the `--test-param` flag:
     *
     * ```
     * $ ya make -t --test-param NAME=VALUE
     * ```
     *
     * You can later access these parameters from tests using this function:
     *
     * ```
     * TEST(Suite, Name) {
     *     EXPECT_EQ(GetTestParam("NAME").value_or("NOT_SET"), "VALUE");
     * }
     * ```
     *
     * @param name          name of the parameter.
     * @return              value of the parameter, as passed to the program arguments,
     *                      or nothing, if parameter not found.
     */
    std::optional<std::string_view> GetTestParam(std::string_view name);
}