project1-5 / celix

Apache Celix
Apache License 2.0
0 stars 0 forks source link

Build GoogleMock #9

Open jsjolen opened 5 years ago

jsjolen commented 5 years ago

It seems like we can't use CppUTest's mocking facilities along with GTest (RUN_ALL_TESTS is overwritten by the include statements). There is however GoogleMock that can be used instead.

modnikhil commented 5 years ago

Been working on this for the past 7 hours. There's been one major bottleneck issue that's blocking the rest of the workflow.

Inside filter_test.cpp the only reason mocking is needed is to count the number of times a specific logging function gets called during the duration of a test case. With CppUTest, it is very easy to mock a free C function as it doesn't require you to provide a mock object. GMock, on the other hand, requires you to provide it the mock object you are calling the logging function on. The issue is, the logging function in addition to a majority of celix functions, are written in C, meaning they aren't object-oriented. A proposed solution was to wrap the free function with an interface that you inherit a mock class from, from which you create a mock object, however, the GMock EXCEPT_CALL method will not recognize the logging function.

Since the mocking functionality is only being used for counting function calls, I'm exploring other ways to do so w/o GMock. Bottom line is, GTest + GMock is not ideal for mocking C functions.

jsjolen commented 5 years ago

This is actually really good information that we should put in the report and probably write in the bug tracker. Good job Nikhil!