For example, saru doesn't come with any nice mocking helpers for C++. There is a basic C++ testing library that comes with it, but writing your own mocks by hand is one of those painful things I mentioned.
Thankfully there's a nice mocking library for C++ from the folks at google, called oddly enough, googlemock. However googlemock is designed to work with googletest - the google testing framework.
Googletest is also great. But its orthogonal to saru, rather than competitive. Saru is cross-language and designed to be more of a test-running wrapper, while googletest is a c++ unit testing library.
So I had three options if I wanted to use google-mock with my code and saru.
- Make the google-mocks work with the saru-cxx library.
- Make google-test output in a format that saru could digest.
- Make saru able to parse google-test output.
So now getting a google-test file working in saru is as trivial as adding a
\\SARU : Format gtestto the top of the test file.. and everything just works :)
(Well you'll need to make sure the compiler can find the right includes and the gtest library.. but thats all)
For example I get this kind of output when running a test suite.
99-misc-00-periodic-processor.cpp::TestFixture::test_process_many : OK gmock_test.cpp::PartyTest.CallsDance : OK gmock_test.cpp::PartyTest.CallsDanceFails : FAILED ==MESSAGE== ==STDERR== gmock_test.cpp:69: Failure Value of: p.party() Actual: false Expected: true