I have researched a lot about gtest/gmock but none of them gave me the right answer. I new to C++ so any help would be really appreciated.
All documentation is covered in the official github repo. The primer documentation also covers a lot of information regarding the test macros. You could use the following summary and the examples linked to choose what you want to use.
TEST()
is useful when you want to write unit tests for static or global functions or simple classes. Example test
TEST_F()
is useful when you need access to objects and subroutines in the unit test. Example test
TEST_P()
is useful when you want to write tests with a parameter. Instead of writing multiple tests with different values of the parameter, you can write one test using TEST_P()
which uses getParam()
and can be instantiated using INSTANTIATE_TEST_SUITE_P()
. Example test