Open lipi opened 7 months ago
Hi. This feature isn't part of the previous release. It's in the about-to-be-released 2.6.0. You can clone the repo if you'd like access to it immediately (make sure you include submodules). Alternatively, you can download the zip file generated by github (in which case you'll need to also grab the zip files for Unity and CException, if you're using it)
I am using the 2.6.0 branch afaik:
% git status
On branch cmock_2_6_rc
Digging into https://github.com/ThrowTheSwitch/CMock/blob/master/lib/cmock_header_parser.rb#L334 it seems that
master
for 4 yearsAdding public:
visibility and a non-static method to the example code:
namespace MyNamespace {
class MyClass {
public:
static int DoesSomething(int a, int b);
int NonStatic(int a);
};
}
creates a mock for DoesSomething
only:
using namespace MyNamespace;
#define MyNamespace_MyClass_DoesSomething_ExpectAndReturn(a, b, cmock_retval) MyNamespace_MyClass_DoesSomething_CMockExpectAndReturn(__LINE__, a, b, cmock_retval)
void MyNamespace_MyClass_DoesSomething_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, int a, int b, int cmock_to_return);
The documentation could be a bit clearer. It says:
Simply use CMock to mock the static member methods and a C++ mocking framework to handle the virtual methods. (Yes, you can mix mocks from CMock and a C++ mocking framework together in the same test!)
It would help if it explicitly stated that non-static methods need a C++ mocking framework, for example
Simply use CMock to mock the static member methods and a C++ mocking framework to handle the virtual methods. (Yes, you can mix mocks from CMock and a C++ mocking framework together in the same test!) Non-static methods can be mocked by a C++ mocking framework.
According to https://github.com/ThrowTheSwitch/CMock/blob/master/docs/CMock_Summary.md the following example
should generate
but the actual mock is missing the declaration.
Running this command:
The generated mock is empty: