Testing with gtest/gmock¶
Before feature requests or bug fixes can be merged into master, the folowing steps should be taken:
Create a new test suite named after the issue, e.g.
Add a test case named
Reproducesthat reproduces the bug. It should fail if the bug is present and pass if the bug is fixed.
Merge the proposed fix into a temporary testing branch.
The reproduction test should fail.
Add a test called “HasNotRegresed” that detects a potential regression. It should pass with the fix and fail before the fix.
Comment out and keep the
Reproducestest case as documentation.
For an example, see keyboardio:Kaleidoscope/tests/issue_840.
Adding a New Test Case¶
Create a new test file, if appropriate.
Choose a new test suite name and create a new test fixture, if appropriate.
Write your test case.
The final include in any test file should be
#include "testing/setup-googletest.h" which should be followed by the macro
SETUP_GOOGLETEST(). This will take care of including headers
commonly used in tests in addtion to gtest and gmock headers.
Any test fixtures should inherit from
VirtualDeviceTest which wraps the test
sim APIs and provides common setup and teardown functionality. The appropriate
header is already imported by
If you need to modify or extend test infrastructure to support your use case,
it can currently be found under
TODO(obra): Fill out this section to your liking.
You can see samples of the desired test style in the example tests.
All existing tests are examples and may be found under
Testing with Aglais/Papilio¶
TODO(obra): Write (or delegate the writing of) this section.