Question

I have a test that is successful (among other things) if a certain callback is run exactly N times. Of course, I can write a bit of code to count how many times the callback is run and then execute a boost::test case against that condition. But this has arisen so often I wonder if I've missed some support for this in boost::test.

Many thanks for any tips.

Was it helpful?

Solution

You should be able to accomplish that with mock objects. Turtle is a mock library that integrates quite well with Boost::Test.

OTHER TIPS

Boost.Test has a subsystem for testing interactions. Admittedly, it is poorly documented, but BOOST_TEST_LOGGED_EXPECTATIONS will do exactly what you need. You do indeed need to mock the party you interfacing with. Boost.Test has a mock class for that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top