Mocking with Boost::Test

被刻印的时光 ゝ 提交于 2019-12-05 00:53:42

Avoid using this template construction for this purpose unless you have some really core piece of code which has to run as fast as possible. If you want to avoid virtual for performance reasons, measure the difference.

Use the template construction only in places where it really makes a difference.

Try Google Mock. EXPECT_CALL is really powerful and saves a lot of code time compared to writing a custom mock.

Avoid mixing the terms Fake and Mock as they have different meaning.

DirectoryIterator<FakeFindFirstFile> LookMaImMocked; // is it a fake or a mock?
Chris Cleeland

Fwiw, I just ran across a new (c. 2011) mock framework called "turtle" that's designed to complement boost::test. It's on sourceforge. I'm just starting down the mocking path on a project and turtle will be my first choice unless it just doesn't work right.

Disclaimer: I'm the author of HippoMocks

I suggest using a mocking framework that can directly mock those API functions. HippoMocks can mock plain C functions and should have no trouble mocking Windows API functions directly. I'll give it a test run tonight and see if it runs.

Hope you're still reading replies :-)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!