-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mocking a class with parameters #72
Comments
Hi, The documentation has a few examples: http://turtle.sourceforge.net/turtle/reference.html#turtle.reference.creation.constructor |
The documentation helps, however the compiler is still giving me a hard time. I'm mocking a class that takes two classes as parameters "MOCK_CONSTRUCTOR(MockClass, 2, (ParameterClass1&, ParameterClass2*));"
I know that there is an existing constructor for BaseClass, but intellisense seems to think there isnt |
You need an «identifier» (see the documentation section I linked):
To understand how to use an «identifier» later on you can read: |
That code really helped me out and I can't believe I didn't see that in my first pass through of the documentation. Is there a way to mock a class that does not have a default constructor? in the software I am testing, none of our classes have default constructors |
Something like
? |
That's helped tremendously. last question i have for you is what exactly constitutes an identifier? when i run the boost test where I am testing my mock class, it keeps saying I have an unknown identifier. I've looked in the code, but can't seem to find anything |
Can you show me the code which fails? |
MOCK_CONSTRUCTOR(MockClassName, 2, BaseClass(ClassParam1&, ClassParam2*), MockClassName); |
You need to set an expectation to define how you expect the constructor to be called, see http://turtle.sourceforge.net/turtle/reference.html#turtle.reference.expectation |
Hello,
I am currently trying to test out mocking a class that has parameters in its constructor, how would i implement that using MOCK_BASE_CLASS? In Visual Studio, there are no red underlines, however when I Compile the program, i get the following error:
no appropriate default constructor available
I am using visual studio 2013 and am developing on Windows Embedded Compact 2013
The text was updated successfully, but these errors were encountered: