0

Using boost 1.33.1 unit tests on Fedora7.

Our code base uses many singletons, so therefore it is not possible to create completely 'clean' unit tests.

What I would like to do is have a test that is executed after all the other tests to make sure the previous tests have tidied up after themselves.

I've tried naming a test suite and the file AAAFinalTest or ZZZFinalTest. But it always appears at the same position. It's probably a link order thing.

Is there any way to force the test to the end?

Neil
  • 11,059
  • 3
  • 31
  • 56
  • I would suggest trying to avoid using singletons, because it hampers effective unit testing (among other things). See some of the answers here: http://stackoverflow.com/questions/2085953/unit-testing-with-singletons. – Oliver Charlesworth Jul 06 '11 at 11:49
  • The singleton pattern is not really the problem. The problem is I want to make sure that there are no left overs from one test that interfere with another. Hmm, yes the problem is the singletons, but I can't really change the code at this point in the project. – Neil Jul 06 '11 at 13:29
  • I have a project with a bunch of singletons in it. They will be phased out some day, but that is another day. For now, I added a "SetInstance()" that I call in the setup for certain tests. Not pretty, but it helps making sane tests. – Jörgen Sigvardsson Jul 06 '11 at 16:42

1 Answers1

0

Why don't you use global fixture?

You will not be able to use testing tools, but you can always report a misuse into std::err or do an assert.

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