简体   繁体   English

VS19 测试资源管理器中未显示 GTest

[英]GTests not showing in VS19 test explorer

I installed the Test Adapter for Google Test for Visual Studio.我为 Visual Studio 的 Google 测试安装了测试适配器。

Then I created a new Google Test Project in the same Solution as the Project I want to test.然后,我在与我要测试的项目相同的解决方案中创建了一个新的 Google 测试项目。

The pre-constructed example shows up in the Test explorer and works fine.预先构建的示例显示在测试资源管理器中并且工作正常。 But when I try to include the declaration of a method I want to test and write a test case for that method the test is not showing up in the Test Explorer anymore.但是当我尝试包含我想要测试的方法的声明并为该方法编写测试用例时,测试不再显示在测试资源管理器中。

test.cpp测试.cpp

#include "pch.h"    //#pragma once & #include "gtest/gtest.h"
#include "../Server/header/server.h"

TEST(TestCaseName, TestName) 
{
    EXPECT_EQ(1, 1);
    EXPECT_TRUE(true);
    //EXPECT_EQ(Multiply(3, 5), 15);
}

server.h服务器.h

#pragma once

int Multiply(int a, int b);

server.cpp服务器.cpp

#include "../header/server.h"

int Multiply(int a, int b)
{
    return a * b;
}

The code above works until I uncomment the line EXPECT_EQ(Multiply(3, 5), 15);上面的代码一直有效,直到我取消注释EXPECT_EQ(Multiply(3, 5), 15); . . After rebuilding the Test will not show up anymore in the Test explorer...重建测试后,测试资源管理器中将不再显示...

Server is configured as static library, the test project as application.服务器配置为 static 库,测试项目为应用程序。 Any help is greatly appreciated!任何帮助是极大的赞赏!

This is a bit late of a response, but after struggling with trying to get GoogleTest working with my own project i came across this question.这有点迟到了,但是在努力让 GoogleTest 与我自己的项目一起工作之后,我遇到了这个问题。

For anyone reading this, you need to check the "Tests" dropdown/section in the Output window to view the test execution errors that might be being logged对于阅读本文的任何人,您需要检查 Output window 中的“测试”下拉列表/部分,以查看可能正在记录的测试执行错误

(also this view does not self-clear like "Debug", or "Build" with each new run - pay attention to the timestamps) (此视图也不会像“调试”或“构建”一样在每次新运行时自行清除 - 请注意时间戳)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM