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
Packages of the current stable version are listed below, or check out 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 me know. Please submit your report and I'll address it.
Downloads & Packages
Operating system specific packages and installers are available below. Select the download that most matches your computer and desired installation wishes.
Binary
Select a download below to have a runnable version installed. 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 Runtime | AMD 64 — Hash — Signature | AMD 64 — Hash — Signature | Not Available | AMD 64 — Hash — Signature | Win 64 Installer — Hash — Signature |
Debug | AMD 64 — Hash — Signature | AMD 64 — Hash — Signature | Not Available | AMD 64 — Hash — Signature | Available within the installer. |
Development | AMD 64 — Hash — Signature | AMD 64 — Hash — Signature | Not Available | AMD 64 — Hash — 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 .