googletest README

The project's README from github.com/google/googletest. As one markdown file: README.md.

GoogleTest

Announcements

Documentation Updates

Our documentation is now live on GitHub Pages at https://google.github.io/googletest/. We recommend browsing the documentation on GitHub Pages rather than directly in the repository.

Release 1.18.0

Release 1.18.0 is now available.

The 1.18.x branch requires at least C++17.

Continuous Integration

We use Google's internal systems for continuous integration.

Coming Soon

Welcome to GoogleTest, Google's C++ test framework!

This repository is a merger of the formerly separate GoogleTest and GoogleMock projects. These were so closely related that it makes sense to maintain and release them together.

Getting Started

See the GoogleTest User's Guide for documentation. We recommend starting with the GoogleTest Primer.

More information about building GoogleTest can be found at googletest/README.md.

Features

Supported Platforms

GoogleTest follows Google's Foundational C++ Support Policy. See this table for a list of currently supported versions of compilers, platforms, and build tools.

Who Is Using GoogleTest?

In addition to many internal projects at Google, GoogleTest is also used by the following notable projects:

GTest Runner is a Qt5 based automated test-runner and Graphical User Interface with powerful features for Windows and Linux platforms.

GoogleTest UI is a test runner that runs your test binary, allows you to track its progress via a progress bar, and displays a list of test failures. Clicking on one shows failure text. GoogleTest UI is written in C#.

GTest TAP Listener is an event listener for GoogleTest that implements the TAP protocol for test result output. If your test runner understands TAP, you may find it useful.

gtest-parallel is a test runner that runs tests from your binary in parallel to provide significant speed-up.

GoogleTest Adapter is a VS Code extension allowing to view GoogleTest in a tree view and run/debug your tests.

C++ TestMate is a VS Code extension allowing to view GoogleTest in a tree view and run/debug your tests.

Cornichon is a small Gherkin DSL parser that generates stub code for GoogleTest.

Contributing Changes

Please read CONTRIBUTING.md for details on how to contribute to this project.

Happy testing!

googletest (google/googletest)

Searching Database…

这是什么?这是 Google 推出的 C++ 测试和模拟(mock)框架,基于 xUnit 架构构建。它合并了原本独立的 GoogleTest 和 GoogleMock 两个项目,现在由 Google 一同维护和发布。
这是一个我要运行的工具,还是要链接到我代码里的库?它是一个要链接到你 C++ 代码中的框架,而不是一个独立的工具:测试用代码编写,编译成一个测试可执行文件,运行这个文件就会执行整组测试。
我该怎么开始用它写测试?先读《用户指南》里的 GoogleTest Primer——团队建议看 GitHub Pages 上的文档,而不是仓库里的版本。构建说明在 googletest/README.md 中;当前版本是 1.18.0。
我的编译器版本够新吗?它需要一个支持 C++17 的编译器:1.18.x 分支至少要求 C++17。除此之外,只需按照 googletest/README.md 从源码构建即可——没有列出其他前置要求。
近期有什么变动可能影响我的构建吗?有一点值得关注:Google 计划引入对 Abseil 的依赖,并已标注为即将到来,所以预计未来的某个版本会加上这个依赖。
有哪些人在生产环境中使用它?Google 内部的大量项目都在用,此外还有支撑 Chrome 和 Chrome OS 的 Chromium 项目、LLVM 编译器、Protocol Buffers 以及 OpenCV 库——它经过了超大规模的实战检验。
在我的平台上能用吗?只要属于 Google《基础 C++ 支持政策》所覆盖的编译器和平台,它都能构建和运行——这份政策的表格里明确列出了支持的编译器、平台和构建工具的版本。
它的断言都能检查些什么?开箱即用就能检查相等、不等、异常等等,你还可以为代码特有的检查自定义断言。失败可以分为致命和非致命:非致命失败后测试可以继续运行。
一个测试能针对多种输入或数据类型运行吗?可以——值参数化测试会用不同的输入值反复运行,类型参数化测试会用不同的数据类型运行。死亡测试(death test)用于验证代码以预期的方式退出,适合检查错误处理路径。
我能只运行单个测试,或者并行运行全部测试吗?两者都行:GoogleTest 提供了运行单个测试、按指定顺序运行以及并行运行的选项。测试是自动发现的,不需要手动维护注册列表。
有编辑器集成或配套工具吗?VS Code 上有 GoogleTest Adapter 和 C++ TestMate,可以在树状视图中查看、运行和调试测试。独立的运行器有 GTest Runner(面向 Windows 和 Linux 的 Qt5 图形界面)、GoogleTest UI 和 gtest-parallel。
What are similar projects?testify, mockito, mockery, ava, Catch2, phpunit, msw, yoga
Creator
google
Size
13.9 MB
Stars
39.6K
Age
11y
Commits · 90 Days