I’ve got some issues with my tests, when running with CTest. The tests are written using GTest, in particular there is a parametrized test case with about a hundred cases. But the same holds for other test (cases) as well.
When I start the test executable from command-line or IDE (Qt-creator), the test (all cases instantiations executed) takes about 93ms.
When I start the test using CTest, it takes 2 seconds each , so more than 200s in total.
How can that be?
And, even more important: How can I fix that?
Definition is as follows:
add_executable(myTest WIN32 testCases.cpp)
target_compile_options(myTest PRIVATE -Wall -Wextra -Wpedantic -Werror)
target_link_libraries(myTest PUBLIC gtest_main)
gtest_discover_tests(myTest)
The test itself is similar to this:
#include <QVariant>
#include <gtest/gtest.h>
struct test_data
{
QString typeName;
QVariant input;
};
class MyTestValues: public testing::TestWithParam<test_data>
{
};
TEST_P(MyTestValues, properties)
{
auto values = GetParam();
// do some testing
}
INSTANTIATE_TEST_SUITE_P(
MyTest,
MyTestValues,
testing::Values(
test_data{ QString{ "bool" }, QVariant{ true } },
test_data{ QString{ "bool" }, QVariant{ false } },
test_data{ QString{ "char" }, QVariant::fromValue(std::numeric_limits<char>::min()) },
test_data{ QString{ "char" }, QVariant::fromValue(std::numeric_limits<char>::max()) },
test_data{ QString{ "char" }, QVariant::fromValue(static_cast<char>(0)) },
test_data{ QString{ "int" }, QVariant{ 42 } },
test_data{ QString{ "int" }, QVariant{ std::numeric_limits<int>::min() } },
test_data{ QString{ "int" }, QVariant{ std::numeric_limits<int>::max() } },
test_data{ QString{ "long" }, QVariant::fromValue(static_cast<long>(-1)) },
test_data{ QString{ "long" }, QVariant::fromValue(std::numeric_limits<long>::min()) },
test_data{ QString{ "long" }, QVariant::fromValue(std::numeric_limits<long>::max()) }
// omitting many other values
));