   C++ Unit Testing Dilemma
  Hi everyone, I'm constructing my own unit testing system for C++ because I'm not happy with any of the available ones. I'v run into a design decision that would be helpful to get some feedback on, so feel free to comment :)The problem has to do with the actual assert functions that can be used in each tests (assertEquals in JUnit etc) and the actual question is: Do I use macros for these instead of TestCase member functions?Use macros?Pros:- We can use __LINE__ to get the exact line the assert was triggered. In my current implementation without macros the best you can get is the line the test was declared on (so its going to be a couple of lines off).- I can use UPPER_CASE for assert functions to make them stand out nicely (code standard dictates this). Test declarations etc will be supported by macros so it might look nicer and more uniform).Cons:- Usual problems with macros, type safety, confusing compiler errors if user types something in etc. Shouldnt be a big problem since assert function calls will be simple.- Function overloading will work much better without macros. We can have an optional assertEquals with three arguments that take a tolerance value (invaluable for floating point checks). Using macros we would need a special macro with a different name like ASSERT_CLOSE().I guess the desciding factor is going to be how you normally write tests. Not getting the exact line the assert failed on is not such a big deal for me, since I have a strong belief that a test should not contain more than 1 or 2 asserts at max. But I will probably release the system later when its done and it would be cool if it was useful to other people.So, does this make sense to you? do you think my head is screwed on wrong? let me know. Just dont tell me I should switch to a different language. I would if I could (Monodevelop's NUnit integration makes me cry happy tears)   
  I usaully try to avoid macros, but IMO this would be an accetable use since that's the only real way to get the line number the check failed on.Also, I would use something like VERIFY instead of ASSERT for macro names. For me, ASSERT implies debug only when you actally want to do unit testing in both debug and release.   ;Quote:Pro: We can use __LINE__ to get the exact line the assert was triggered. In my current implementation without macros the best you can get is the line the test was declared on (so its going to be a couple of lines off).You can still use it with functions, if you provide it as a parameter. But that will be cumbersome to type in for the users of course.Illco   ;  yeah, I'm actually using CHECK_*. I only used assert in the example since thats what most people are familiar with from JUnit and NUnit.Quote:You can still use it with functions, if you provide it as a parameter. But that will be cumbersome to type in for the users of course.Anything that requires more typing is not ok. One of the reasons I'm coding this is because CppUnit requires so much effort to write tests.   ;  I'v stopped working on my test suit now after finding CppTestHarness (released very recently). It already implements all my ideas perfectly (and some other stuff) and is lightweight and pretty portable. Check it out!   