New to cpp (Java guy).
I have 3rd party library that has method sendMail(txt). I don't want to test the library. i want to test my own method, so in order to do this , i need to mock the library calls .
My own method is looking like this:
#include "mailsender.h"
int run(txt){
analysis(txt);
...
...
int status = sendMail(txt);//sendMail is a 3rd party library call. i need to mock it.its not part of the unit test
return status;
}
In Java the mailsender was interface and it was injected to my class, so in case of test i inject mock. What is a good practice in cpp to mock library calls? I can wrap the 3rd party library call in a class and inject this class, but i am looking for something simpler and for the common practice (maybe ifndf).
I am familiar with googlemock. googlemock allow me to mock classes . i am not aware to option how to mock a call in my tested method.
See Question&Answers more detail:os