mindw / googlemock

Automatically exported from code.google.com/p/googlemock
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Need a way to check expectations without Clearing/ Verifying them #155

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
A complement to http://code.google.com/p/googlemock/issues/detail?id=132.

I'm working on a utility class (QSignalMock) for use with Qt's signals-slots 
framework to make verifying that a class emits the correct signals much easier 
- some further details are in my (SSJ's) posts, here:

http://groups.google.com/group/googlemock/browse_thread/thread/4538329ca3dae9ec

Emission of signals can be asynchronous, and we need to be able to wait around 
for a timeout period before Verifying the expectations, while at the same time 
waiting no longer than is required for the EXPECTed signals to be emitted.

To do this, I would like, in the destructor of QSignalMock, to be able to check 
whether the expectations are currently satisfied and if not, to wait around for 
a timeout or for them to become satisfied (whichever comes first), re-checking 
whenever a new signal comes in.  Mock::VerifyAndClearExpectations() won't do, 
alas, as I may need to check more than once.

An addition of e.g. bool Mock::CheckExpectations() which returns whether the 
mock's expecations are currently satisfied and has no side-effects would be 
very, very helpful.  This request seems quite Qt-specific, but I can see it 
being useful to other people dealing with asynchronous operations.

Original issue reported on code.google.com by ssj...@hotmail.com on 7 Mar 2012 at 8:58

GoogleCodeExporter commented 9 years ago
This bug is requesting a "peek" function that has no side effect (i.e., it 
should not generate a failure). This is to facilitate testing based on polling. 
But testing based on polling is hacky and unreliable - it indicates a design 
smell.  I don't want to encourage that.  I think his problem is probably better 
solved using synchronization primitives properly, outside of gMock.

Original comment by j...@google.com on 16 Nov 2012 at 7:30