GoogleTest - Google Testing and Mocking Framework
2024-02-20 14:42:54 +00:00
.github Update 12-refactor_request.yml 2024-02-14 17:34:30 +00:00
ci Add support for Bzlmod for the next release 2024-01-25 10:27:52 -08:00
coroutines trialling images 2024-02-20 14:42:54 +00:00
docs Add anchor for expectation ordering note 2024-02-13 13:55:04 -08:00
googlemock gmock updates applied and compiling 2024-02-14 13:26:30 +00:00
googletest change not needed once cotest vars fixed 2024-02-14 13:48:13 +00:00
.clang-format Googletest export 2021-01-15 15:53:39 -05:00
.gitignore Add support for Bzlmod for the next release 2024-01-25 10:27:52 -08:00
BUILD.bazel Support Fuchsia target builds. 2024-02-13 20:56:40 -08:00
CMakeLists.txt CMakefile to build coroutines subproject 2024-02-14 10:53:26 +00:00
CONTRIBUTING.md Merge pull request #4343 from sthd:http-to-https 2023-08-22 10:24:02 -07:00
CONTRIBUTORS Add myself to Contributors 2024-01-31 21:11:21 +09:00
googletest_deps.bzl Add support for Bzlmod for the next release 2024-01-25 10:27:52 -08:00
LICENSE Wrong LICENSE file, sorry. Corrected. [skip ci] 2017-12-08 23:16:46 -05:00
MODULE.bazel Add support for Bzlmod for the next release 2024-01-25 10:27:52 -08:00
README.md Update README.md 2024-02-14 18:43:01 +00:00
WORKSPACE Add support for Bzlmod for the next release 2024-01-25 10:27:52 -08:00
WORKSPACE.bzlmod Add support for Bzlmod for the next release 2024-01-25 10:27:52 -08:00

Cotest

Cotest is an extension of Google Test with fully integrated support for coroutines:

  • as contexts within which to run checking code and actions,
  • and to execute the code under test.

Cotest allows for a linear test case layout, in which the test coroutine launches the code under test, and then accepts and returns mock calls in a single sequence of C++ statements. Cotest can do this without needing a data structure populated with expected future events. The user directly implements the test coroutine and can insert arbitrary logic to decide how to respond to mock calls and results from code under test, without needing to split the code into multiple lambda actions.

Cotest supports matching on both watches (similar to GMock expectations) and inside the coroutine body (a test coroutine can drop a mock call and GMock's matching search will continue). Cotest actions are coded directly into the coroutine body by the user. Cardinality is inferred from the execution state of the coroutine.

Cotest supports multiple test coroutines: these will see mock calls with priority established by their watches, which may be interleaved with GMock expectations. Cotest permits multiple overlapping launches of code under test: in the coroutine model there is no freely concurrent execution, but a test coroutine can control the order in which mock calls are allowed to return.

This project is a fork of Google Test, and changes to gtest/gmock source code have been kept minimal. C++14.

To build and run the tests

From repo top level:

mkdir build
cd build
cmake -Dcoro_build_tests=ON -Dgtest_build_tests=ON -Dgtest_build_samples=ON -Dgmock_build_tests=ON -DCMAKE_BUILD_TYPE=Debug -DGOOGLETEST_VERSION=0 -DCOROUTINES_VERSION=0 ../
make
ctest

This will run the googletest tests as well as the cotest tests. Use -R ^co for just the cotest tests.

Selected examples

  • Unit tests for a code sample that (mis-)uses a mutex.
  • Examples of serverised testing style.

There are many more cotest scripts in test/