use gtest_discover_tests for creating tests (#1195)

This commit is contained in:
Victor Vazquez 2020-12-16 23:00:01 +00:00 committed by GitHub
parent dacd6aa6c1
commit 1bfbaf7330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View File

@ -59,7 +59,7 @@ target_include_directories (azure-core-test PRIVATE $<BUILD_INTERFACE:${CMAKE_CU
target_link_libraries(azure-core-test PRIVATE azure-core gtest gmock)
# gtest_add_tests will scan the test from azure-core-test and call add_test
# gtest_discover_tests will scan the test from azure-core-test and call add_test
# for each test to ctest. This enables `ctest -r` to run specific tests directly.
gtest_add_tests(TARGET azure-core-test
gtest_discover_tests(azure-core-test
TEST_PREFIX azure-core.)

View File

@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include <gtest/gtest.h>
#include <curl/curl.h>
#include <gtest/gtest.h>
int main(int argc, char** argv)
{

View File

@ -9,16 +9,18 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
add_compile_definitions(AZURE_TEST_DATA_PATH="${CMAKE_BINARY_DIR}")
include(GoogleTest)
add_executable (
azure-template-test
ut/template_test.cpp
)
target_link_libraries(azure-template-test PRIVATE Azure::azure-template)
target_link_libraries(azure-template-test PRIVATE Azure::azure-template gtest_main)
if (MSVC)
target_compile_options(azure-template-test PUBLIC /wd6326 /wd26495 /wd26812)
endif()
add_gtest(azure-template-test)
gtest_discover_tests(azure-template-test TEST_PREFIX azure-template.)