0

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.

jma
  • 3,580
  • 6
  • 40
  • 60
  • Twelve days have passed. I conclude that the best approach is to handle the case myself, as indeed I already do. – jma Mar 19 '12 at 16:53

2 Answers2

0

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.

Gennadiy Rozental
  • 1,905
  • 2
  • 13
  • 17
0

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

  • This is an interesting and useful approach, thanks. In my simple case, I'm not sure it adds much beyond what I get from handling the count myself, but in slightly more complex scenarios I suspect it would be quite helpful. [Since it's a useful answer and the only answer after many weeks, I'm also accepting it.] – jma Apr 03 '12 at 17:11