Google Test Adapter 项目使用教程
1. 项目目录结构及介绍
Google Test Adapter (GTA) 是一个为 Visual Studio 提供的对 C++ 编写的 Google Test 框架测试进行发现和执行的项目。项目目录结构如下:
GoogleTestAdapter/
├── .gitattributes
├── .gitconfig
├── .gitignore
├── .mailmap
├── appveyor.yml
├── build_preparation.bat
├── codecov.yml
├── Common.props
├── GoogleTestAdapter/
│ ├── GoogleTestAdapter.csproj
│ ├── Properties/
│ │ └── AssemblyInfo.cs
│ └── Templates/
│ └── vsix/
├── GoogleTestNuGet/
│ ├── GoogleTestAdapter NuGet.csproj
│ └── Properties/
│ └── AssemblyInfo.cs
├── LICENSE.md
├── NuGet.config
├── README.md
├── ResolveTTs.proj
├── TestAdapterFlavor.props
├── ThirdParty/
├── Tools/
├── Troubleshooting/
└── Visual Studio Integration/
GoogleTestAdapter/
:包含 Google Test Adapter 的主要代码和项目文件。GoogleTestNuGet/
:包含用于 NuGet 包的项目文件。ThirdParty/
:可能包含第三方库或工具。Tools/
:包含构建和部署脚本等工具。Troubleshooting/
:包含故障排除指南。Visual Studio Integration/
:包含与 Visual Studio 集成的相关文件。
2. 项目的启动文件介绍
项目的启动主要通过 Visual Studio 扩展安装或 NuGet 包管理器来完成。
通过 Visual Studio 市场安装
- 打开 Visual Studio。
- 转到 "工具" > "扩展和更新"。
- 搜索 "Google Test Adapter" 并安装。
通过 NuGet 包安装
- 在 Visual Studio 中打开您的 Google Test 项目。
- 使用 NuGet 包管理器添加对
Google.Test.Adapter
包的引用。
安装后,重启 Visual Studio,您的测试将会显示在测试资源管理器中。
3. 项目的配置文件介绍
Google Test Adapter 提供了多种配置方式:
- Visual Studio 选项:在 Visual Studio 的 "工具" > "选项" 中找到 "Google Test Adapter" 部分,可以设置全局选项。
- GTA 工具栏:在 Visual Studio 中,可以通过 GTA 工具栏设置一些重要的运行时选项。
- 解决方案设置文件:通过 XML 配置文件,可以共享设置。配置文件应与
.sln
文件在同一目录下,文件名与.sln
文件相同,但扩展名为.gta.runsettings
。 - Visual Studio 用户设置文件:通过 "测试" > "测试设置" 菜单选择设置文件。
- 环境变量:
GTA_FALLBACK_SETTINGS
环境变量指定的设置文件将在特定情况下使用。
配置文件的格式包含 <GoogleTestAdapterSettings>
节点,其中包含解决方案设置和项目设置。这些设置将根据优先级合并,最终确定每个测试可执行的设置。
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考