Regarding C++ google unit test framework for socket communication

1,565 views
Skip to first unread message

Amit Kulkarni

unread,
Dec 4, 2015, 2:59:38 PM12/4/15
to Google C++ Testing Framework
Hi 

I am using google unit test framework (googletest-master\googletest) for executing unit test for my C++ code.
My C++ code internally communicate with another process using socket programming. 
Can I use googletest to do unit testing for a code which internally calls socket api's and expects some output asynchronously?

If yes how to achieve this?

Thanks
Amit

Alex Shaver

unread,
Dec 5, 2015, 4:36:32 PM12/5/15
to Google C++ Testing Framework
I usually do this with googlemock. Essentially, I make some wrapper class around the network interface, then mock it out with gmock. If you're not familiar, it's a great tool that allows you to test if a class's functions are called, and to provide injectable results that bypass the normal class's actual function (ie, you can make it act as if some network socket read a string into some buffer)
Reply all
Reply to author
Forward
0 new messages