Boost logo

Boost :

Subject: Re: [boost] What Should we do About Boost.Test?
From: Sohail Somani (sohail_at_[hidden])
Date: 2012-09-30 10:02:05


On 29/09/2012 3:31 PM, Gennadiy Rozental wrote:
>> >Anyway, I haven't looked back yet and (sorry) I'm not sure I will.
>> >Google Mock itself is unbelievably useful.
> Frankly, I can't see what the fuss is all about. An approach taken by
> Boost.Test is marginally better in my opinion. Mocks are deterministic
> and test case should not need to spell out expectations. Writing mocks
> is just as easy. You can see an example here:
>
> .../libs/test/example/logged_exp_example.cpp
>
> There is a potential for some improvement, but it is already better
> than anything else I know (IMO obviously).

http://svn.boost.org/svn/boost/trunk/libs/test/example/logged_exp_example.cpp

I looked at the example and I couldn't really understand it. However,
here are the reasons I prefer Google Mock to writing my own mocks over
and over:

1. The psychological barrier of creating yet-another-class. Maybe this
is PTSD from that one time I had to use Java or something.

2. The main things in my mock tests that change are the values, not the
types.

Google Mock makes it easy for me to write quick tests for when values
change:

   MockThingy mock;

   EXPECT_CALL(mock,something(100))
     .WillOnce(Return(32));

The above will take a *generic* mocked class and give it behaviour. This
particular test expects a call to the "something" function with a
parameter of 100 and will return 32 once.

The important thing is that I can re-use the mocked class for other
tests as well. I can't immediately see how this is possible with the
example you have shown.

As for Boost Test vs Google Test, I don't really prefer one over the
other. I'm only using Google Test because it was easy in this particular
case.

I would be happy if you could explain your example though because I
don't understand what it's doing.

Sohail


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk