Boost logo

Boost Users :

Subject: [Boost-users] [Boost.UTF] Suggestion - test tracking
From: Adam Nielsen (a.nielsen_at_[hidden])
Date: 2010-04-07 09:09:56


Hi all,

I have a suggestion for the Boost unit-test library. If this is already
possible and I've just missed it, please let me know.

It would be nice if there was a sure-fire way to guarantee certain parts of
the code were being tested. For example an if/else statement would ideally
have tests that cover both execution paths, but at the moment this relies on
coding the tests correctly. It's possible to make a mistake in the test and
cause it to succeed without actually testing the code in question, and because
the test succeeds you may never notice.

Would it be possible to have something like a BOOST_TESTED_BY macro, which
causes the named test to fail if it completes without running that line? (As
well as documenting where that part of the code is tested.) For example:

  if (condition) {
    BOOST_TESTED_BY(my_test);
  } else {
    BOOST_TESTED_BY(my_other_test);
  }

  BOOST_AUTO_TEST_CASE(my_test)
  {
    // This test fails if BOOST_TESTED_BY(my_test) doesn't run
  }

Of course this is a simplified example, you'd probably want counts and things
as well, but I thought it might be a useful addition to the test framework
(assuming it can't be done already!)

Thanks,
Adam.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net