Итак, я работаю над созданием моих первых модульных тестов.Я использую Google Test, версию, которая в настоящее время встроена в Visual Studio 2017. Это попытка проверки концепции, поэтому она очень проста.
У меня есть проект решения для тестового кода:test.cpp
#include "pch.h"
#include "../ConsoleApplication1/ConsoleApplication1.cpp"
TEST(SumTest, FirstTest) {
EXPECT_EQ(6, sum(2, 4));
}
TEST(SumTest, SecondTest) {
EXPECT_EQ(1, 1);
EXPECT_TRUE(true);
}
И у меня есть простой метод для тестирования в ConsoleApplication1.cpp
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int sum(int a, int b);
int main()
{
int x = sum(2, 4);
printf("The answer is: %d \n", x);
}
int sum(int a, int b) {
return a + b;
}
Все компилируется нормально, но когда я нажимаю «Run All» в меню Test Explorer, Я получаю следующий вывод:
[5/7/2018 4:17:42 PM Informational] ------ Run test started ------
[5/7/2018 4:17:43 PM Informational] Test Adapter for Google Test: Test execution starting...
[5/7/2018 4:17:43 PM Informational] Found 0 tests in executable C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\Google Test - Sandbox.exe
[5/7/2018 4:17:43 PM Informational] Found 0 tests in executable C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\ConsoleApplication1.exe
[5/7/2018 4:17:43 PM Informational] Running 0 tests...
[5/7/2018 4:17:43 PM Informational] Google Test execution completed, overall duration: 00:00:00.3666448
[5/7/2018 4:17:43 PM Warning] Could not locate debug symbols for 'C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\ConsoleApplication1.exe'. To make use of '--list_content' discovery, ensure that debug symbols are available or make use of '<ForceListContent>' via a .runsettings file.
[5/7/2018 4:17:44 PM Warning] Could not locate debug symbols for 'C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\Google Test - Sandbox.exe'. To make use of '--list_content' discovery, ensure that debug symbols are available or make use of '<ForceListContent>' via a .runsettings file.
[5/7/2018 4:17:44 PM Warning] No test is available in C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\ConsoleApplication1.exe C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\Google Test - Sandbox.exe. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[5/7/2018 4:17:44 PM Informational] ========== Run test finished: 0 run (0:00:01.9324761) ==========
[5/7/2018 4:20:39 PM Informational] ------ Discover test started ------
[5/7/2018 4:20:40 PM Informational] Test Adapter for Google Test: Test discovery starting...
[5/7/2018 4:20:40 PM Informational] Found 0 tests in executable C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\Google Test - Sandbox.exe
[5/7/2018 4:20:40 PM Informational] Test discovery completed, overall duration: 00:00:00.3954411
[5/7/2018 4:20:40 PM Warning] Could not locate debug symbols for 'C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\Google Test - Sandbox.exe'. To make use of '--list_content' discovery, ensure that debug symbols are available or make use of '<ForceListContent>' via a .runsettings file.
[5/7/2018 4:20:40 PM Informational] ========== Discover test finished: 0 found (0:00:01.8597435) ==========
[5/7/2018 4:20:47 PM Informational] ------ Discover test started ------
[5/7/2018 4:20:48 PM Informational] Test Adapter for Google Test: Test discovery starting...
[5/7/2018 4:20:49 PM Informational] Found 0 tests in executable C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\Google Test - Sandbox.exe
[5/7/2018 4:20:49 PM Informational] Test discovery completed, overall duration: 00:00:00.3670275
[5/7/2018 4:20:49 PM Warning] Could not locate debug symbols for 'C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\ConsoleApplication1.exe'. To make use of '--list_content' discovery, ensure that debug symbols are available or make use of '<ForceListContent>' via a .runsettings file.
[5/7/2018 4:20:49 PM Warning] Could not locate debug symbols for 'C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\Google Test - Sandbox.exe'. To make use of '--list_content' discovery, ensure that debug symbols are available or make use of '<ForceListContent>' via a .runsettings file.
[5/7/2018 4:20:49 PM Informational] ========== Discover test finished: 0 found (0:00:01.873206) ==========
[5/7/2018 4:21:36 PM Informational] ------ Run test started ------
[5/7/2018 4:21:37 PM Informational] Test Adapter for Google Test: Test execution starting...
[5/7/2018 4:21:38 PM Informational] Found 0 tests in executable C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\ConsoleApplication1.exe
[5/7/2018 4:21:38 PM Informational] Found 0 tests in executable C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\Google Test - Sandbox.exe
[5/7/2018 4:21:38 PM Informational] Running 0 tests...
[5/7/2018 4:21:38 PM Informational] Google Test execution completed, overall duration: 00:00:00.3844604
[5/7/2018 4:21:38 PM Warning] Could not locate debug symbols for 'C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\ConsoleApplication1.exe'. To make use of '--list_content' discovery, ensure that debug symbols are available or make use of '<ForceListContent>' via a .runsettings file.
[5/7/2018 4:21:38 PM Warning] Could not locate debug symbols for 'C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\Google Test - Sandbox.exe'. To make use of '--list_content' discovery, ensure that debug symbols are available or make use of '<ForceListContent>' via a .runsettings file.
[5/7/2018 4:21:38 PM Warning] No test is available in C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\ConsoleApplication1.exe C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\Google Test - Sandbox.exe. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[5/7/2018 4:21:38 PM Informational] ========== Run test finished: 0 run (0:00:02.0203611) ==========
[5/7/2018 4:27:21 PM Informational] ------ Run test started ------
[5/7/2018 4:27:34 PM Informational] Test Adapter for Google Test: Test execution starting...
[5/7/2018 4:27:35 PM Informational] Found 0 tests in executable C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\Google Test - Sandbox.exe
[5/7/2018 4:27:35 PM Informational] Found 0 tests in executable C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\ConsoleApplication1.exe
[5/7/2018 4:27:35 PM Informational] Running 0 tests...
[5/7/2018 4:27:35 PM Informational] Google Test execution completed, overall duration: 00:00:00.6936342
[5/7/2018 4:27:35 PM Warning] Could not locate debug symbols for 'C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\ConsoleApplication1.exe'. To make use of '--list_content' discovery, ensure that debug symbols are available or make use of '<ForceListContent>' via a .runsettings file.
[5/7/2018 4:27:35 PM Warning] Could not locate debug symbols for 'C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\Google Test - Sandbox.exe'. To make use of '--list_content' discovery, ensure that debug symbols are available or make use of '<ForceListContent>' via a .runsettings file.
[5/7/2018 4:27:35 PM Warning] No test is available in C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\ConsoleApplication1.exe C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\Google Test - Sandbox.exe. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[5/7/2018 4:27:35 PM Informational] ========== Run test finished: 0 run (0:00:14.3144745) ==========
[5/7/2018 4:27:59 PM Informational] ------ Run test started ------
[5/7/2018 4:28:11 PM Informational] Test Adapter for Google Test: Test execution starting...
[5/7/2018 4:28:11 PM Informational] Found 0 tests in executable C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\ConsoleApplication1.exe
[5/7/2018 4:28:11 PM Informational] Found 0 tests in executable C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\Google Test - Sandbox.exe
[5/7/2018 4:28:11 PM Informational] Running 0 tests...
[5/7/2018 4:28:11 PM Informational] Google Test execution completed, overall duration: 00:00:00.6451099
[5/7/2018 4:28:11 PM Warning] Could not locate debug symbols for 'C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\ConsoleApplication1.exe'. To make use of '--list_content' discovery, ensure that debug symbols are available or make use of '<ForceListContent>' via a .runsettings file.
[5/7/2018 4:28:12 PM Warning] Could not locate debug symbols for 'C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\Google Test - Sandbox.exe'. To make use of '--list_content' discovery, ensure that debug symbols are available or make use of '<ForceListContent>' via a .runsettings file.
[5/7/2018 4:28:12 PM Warning] No test is available in C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\ConsoleApplication1.exe C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\Google Test - Sandbox.exe. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[5/7/2018 4:28:12 PM Informational] ========== Run test finished: 0 run (0:00:12.9601734) ==========
[5/7/2018 4:29:59 PM Informational] ------ Run test started ------
[5/7/2018 4:30:59 PM Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Failed to initialize client proxy: could not connect to test process.
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, CancellationToken cancellationToken)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyExecutionManager.StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler)
[5/7/2018 4:30:59 PM Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Failed to initialize client proxy: could not connect to test process.
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, CancellationToken cancellationToken)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyExecutionManager.StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler)
[5/7/2018 4:30:59 PM Informational] ========== Run test finished: 0 run (0:01:00.2319577) ==========
[5/7/2018 4:34:34 PM Informational] ------ Discover test started ------
[5/7/2018 4:34:36 PM Informational] Test Adapter for Google Test: Test discovery starting...
[5/7/2018 4:34:36 PM Informational] Found 0 tests in executable C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\Google Test - Sandbox.exe
[5/7/2018 4:34:36 PM Informational] Test discovery completed, overall duration: 00:00:00.3801077
[5/7/2018 4:34:36 PM Warning] Could not locate debug symbols for 'C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\ConsoleApplication1.exe'. To make use of '--list_content' discovery, ensure that debug symbols are available or make use of '<ForceListContent>' via a .runsettings file.
[5/7/2018 4:34:36 PM Warning] Could not locate debug symbols for 'C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\Google Test - Sandbox.exe'. To make use of '--list_content' discovery, ensure that debug symbols are available or make use of '<ForceListContent>' via a .runsettings file.
[5/7/2018 4:34:36 PM Informational] ========== Discover test finished: 0 found (0:00:01.89196) ==========
[5/7/2018 4:34:41 PM Informational] ------ Run test started ------
[5/7/2018 4:34:42 PM Informational] Test Adapter for Google Test: Test execution starting...
[5/7/2018 4:34:43 PM Informational] Found 0 tests in executable C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\ConsoleApplication1.exe
[5/7/2018 4:34:43 PM Informational] Found 0 tests in executable C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\Google Test - Sandbox.exe
[5/7/2018 4:34:43 PM Informational] Running 0 tests...
[5/7/2018 4:34:43 PM Informational] Google Test execution completed, overall duration: 00:00:00.3975222
[5/7/2018 4:34:43 PM Warning] Could not locate debug symbols for 'C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\ConsoleApplication1.exe'. To make use of '--list_content' discovery, ensure that debug symbols are available or make use of '<ForceListContent>' via a .runsettings file.
[5/7/2018 4:34:43 PM Warning] Could not locate debug symbols for 'C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\Google Test - Sandbox.exe'. To make use of '--list_content' discovery, ensure that debug symbols are available or make use of '<ForceListContent>' via a .runsettings file.
[5/7/2018 4:34:43 PM Warning] No test is available in C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\ConsoleApplication1.exe C:\Users\ruggiero\source\repos\Google Test - Sandbox\Debug\Google Test - Sandbox.exe. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[5/7/2018 4:34:43 PM Informational] ========== Run test finished: 0 run (0:00:01.9803681) ==========
Кажется, он не обнаруживает ни одного из написанных мною тестов, и я не уверен, почему.