[squid-dev] cppunit -> googletest / gmock?

Francesco Chemolli gkinkie at gmail.com
Sat May 30 17:27:12 UTC 2020


Hi all,
   starting from a PR in a conversation with Alex about our current
approach to unit testing being painful, I've checked what alternatives
would we have and how practical would they be.

An easy first option would be googletest/googlemock.

On a lazy afternoon, I've tried seeing how useful/painful it would be to
try it, by porting one test over - it's quite trivial and doesn't require
mocking, so I'll try a more complicated one next - to start a conversation
about the topic.

You can find the test branch at https://github.com/kinkie/squid/tree/gtest .
I've only touched two files, a newly-created src/tests/testMemGtest and
src/Makefile.am .

The output from the test run is at https://paste.ubuntu.com/p/3sgTDN7rNm/

What do you think?

My initial thoughts:
- it is somewhat simpler and more powerful than cppunit
- setting the test environment up is easy but at this time it can only be
done from source. Adding it to the build farm images is straightforward
- the license is BSD 3-clause new (
https://github.com/google/googletest/blob/master/LICENSE)
- googlemock promises to be vastly superior to our current approach
- porting memTest took me about one hour, mostly caused by us including
cppunit headers from squid.h (WUT? A PR is coming up to unentangle that)

-- 
    Francesco
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squid-cache.org/pipermail/squid-dev/attachments/20200530/65686d5d/attachment.html>


More information about the squid-dev mailing list