Qt Mocks
Qt Test Code Mocking Library
Description
Qt Mocks is inspired by Google Mocks, but designed to be used with Qt Test.
Stable Version 0.7.0
There are packages of the current stable version below, or checkout the stable release branch using Mercurial .
Features
- Common test matchers for expected values.
- Simple mocking and expectation testing.
- Common stream insertion support for common Qt container types.
- When a type does not have a stream insertion operator, the raw bytes of the object will be used instead.
Example
Below is an illustration of performing a simple Qt test.
struct Example : QObject { Q_OBJECT struct Mocked : Actual { QMOCK(qint32, foo, (const Bar&), (const)); }; private slots: void test() {Mocked
mock{};Expectations
expect{mock}; QVERIFY_CALL(expect, foo, (const Bar&), (const)) .will(give(42)) .times(1); const auto result{doFunc(mock)}; QVERIFY_THAT(result, equals(360)); } };
Known Issues
- Some tests require the explicit expected testing type to be passed.
- When creating a mock that has member functions that have the same name, specifiers, and number of parameter types, but only differ in the types to that function, it'll result in a compilation error. The workaround is to add an extra comma, ",", in the mock's specifier list.
Report Issues
If you have an issue, enhancement, or wish that you would like to let us know. Please submit your report and I'll address it.
Downloads & Packages
Operating system specific packages and installers are available below. Select the download which most matches your computer and desired install wishes.
Binary
Select a download below to have a runnable version installed onto your computer. All
binary packages are signed using this
FSF key
.
The signatures can be verified using
GNU Privacy Guard
.
Type | Debian | Fedora | macOS | Mageia | Windows |
---|---|---|---|---|---|
Executable | AMD 64 — Hash Verification — Verification Signature | AMD 64 — Hash Verification — Verification Signature | Not Available | AMD 64 — Hash Verification — Verification Signature | Win 64 Installer — Hash Verification — Verification Signature |
Debug | AMD 64 — Hash Verification — Verification Signature | AMD 64 — Hash Verification — Verification Signature | Not Available | AMD 64 — Hash Verification — Verification Signature | Available within the installer. |
Development | AMD 64 — Hash Verification — Verification Signature | AMD 64 — Hash Verification — Verification Signature | Not Available | AMD 64 — Hash Verification — Verification Signature | Available within the installer. |
Source
Select the download below to have the source code extracted onto your computer.
Development
You can track the development version by using Mercurial on the default branch .
Repository hosting is generously provided by Octobus and Clever cloud .