Vadim Zeitlin
2013-03-23 13:13:50 UTC
Hello,
I've done my first modifications to the SOCI unit tests recently and it
wasn't a very pleasant experience. The 2 main reasons for this are the
rather unusual tests organization and the use of assert() instead of some
more advanced mechanism. I'm especially riled by the latter because
assert() is just not good enough: it doesn't show you which test failed, it
doesn't show you the values of the variables with which it failed and it
doesn't allow you to continue running past the first failure.
So I wonder what do you think about using some testing framework instead.
Considering SOCI existing dependencies on Boost it could make sense to use
Boost.Test (http://www.boost.org/doc/libs/1_53_0/libs/test/doc/html/index.html)
but OTOH all the current dependencies are optional, while this one would be
semi-required as it's really nice to be able to run tests even if you don't
use Boost.
Hence an alternative solution: CATCH. This means "C++ AutomatedTest Cases
in Headers" and, as you can see at https://github.com/philsquared/Catch [1]
it is just a single header and all you need to do to start using it is to
just include it. It is also really nice in that it's enough to write
CHECK( ul == 4000000000ul );
to see the value of "ul" if the test fails, i.e. you have just a single
CHECK() which does everything, whereas with Boost.Test you need to use a
specific macro:
BOOST_CHECK_EQUAL( ul, 4000000000ul );
Personally I think this is a great idea but I admit that I haven't used
CATCH in really big test suites so I don't know what effect all the
meta-programming machinery necessary to make the above work has on the
compile times. Still, I believe CATCH would be a good fit for SOCI, so what
do you think about starting to use it?
And if not, using Boost.Test would still be much better than relying on
bad old assert()...
Finally, this is definitely not 3.2-critical but it would be nice to have
an agreement about this before the tests need to be modified the next time.
Regards,
VZ
[1] If you want to see the project activity, look at "integration" branch,
not the default "master".
I've done my first modifications to the SOCI unit tests recently and it
wasn't a very pleasant experience. The 2 main reasons for this are the
rather unusual tests organization and the use of assert() instead of some
more advanced mechanism. I'm especially riled by the latter because
assert() is just not good enough: it doesn't show you which test failed, it
doesn't show you the values of the variables with which it failed and it
doesn't allow you to continue running past the first failure.
So I wonder what do you think about using some testing framework instead.
Considering SOCI existing dependencies on Boost it could make sense to use
Boost.Test (http://www.boost.org/doc/libs/1_53_0/libs/test/doc/html/index.html)
but OTOH all the current dependencies are optional, while this one would be
semi-required as it's really nice to be able to run tests even if you don't
use Boost.
Hence an alternative solution: CATCH. This means "C++ AutomatedTest Cases
in Headers" and, as you can see at https://github.com/philsquared/Catch [1]
it is just a single header and all you need to do to start using it is to
just include it. It is also really nice in that it's enough to write
CHECK( ul == 4000000000ul );
to see the value of "ul" if the test fails, i.e. you have just a single
CHECK() which does everything, whereas with Boost.Test you need to use a
specific macro:
BOOST_CHECK_EQUAL( ul, 4000000000ul );
Personally I think this is a great idea but I admit that I haven't used
CATCH in really big test suites so I don't know what effect all the
meta-programming machinery necessary to make the above work has on the
compile times. Still, I believe CATCH would be a good fit for SOCI, so what
do you think about starting to use it?
And if not, using Boost.Test would still be much better than relying on
bad old assert()...
Finally, this is definitely not 3.2-critical but it would be nice to have
an agreement about this before the tests need to be modified the next time.
Regards,
VZ
[1] If you want to see the project activity, look at "integration" branch,
not the default "master".