Vadim Zeitlin
2015-03-25 16:30:31 UTC
Hello,
While we're discussing other "strategic" things, I'd like to also return
to something that was mentioned a couple of times in the past but without
any definitive conclusion, unless I missed it: could we start using CATCH
(http://catch-lib.net/) in the unit tests?
Currently the tests use assert() which is far from ideal (I could give
details but I'll skip this for now because I think everybody realizes the
problems with assert() already). The only advantage of the current approach
is that it has no third party dependencies. I'd like to use a header-only
testing framework to preserve this advantage as much as possible while also
getting all the nice features you'd expect from such framework and CATCH is
the best candidate I know of.
Assuming there are no objections to using it, I'd like to add catch.hpp
(https://github.com/philsquared/Catch/blob/master/single_include/catch.hpp)
directly to SOCI repository, e.g. as tests/catch.hpp. I don't think it's
worth the trouble to use a submodule for it, but we could do this too if
people prefer it.
I am less sure about how to handle the transition from assert() to CATCH.
One possibility would be to just globally replace all asserts with
REQUIRE() macros. This would be suboptimal (if only because some of the
asserts should probably be replaced with CHECK(), to allow the tests to
continue if one of them fails), but should be relatively simple to do. And
if we do this, we should probably also move all the files from tests/assert
one directory level up, as the "assert" part wouldn't make any sense any
more.
Another possibility would be to start a parallel tests hierarchy in
tests/catch. I'm not too kin on it, mostly because I don't like duplication
but also because this would require changing the CMake files and I'd rather
avoid this.
Finally, it would be possible to just start using CATCH for the checks
without changing anything in the existing ones. I don't like this one too
much neither because it's going to be confusing to have different macros
used in different places, but it's definitely the simplest one.
What would be the preferred approach? Or maybe someone sees a better one,
not listed above? And, of course, do we have a consensus for using CATCH in
the first place?
Thanks in advance for your thoughts,
VZ
While we're discussing other "strategic" things, I'd like to also return
to something that was mentioned a couple of times in the past but without
any definitive conclusion, unless I missed it: could we start using CATCH
(http://catch-lib.net/) in the unit tests?
Currently the tests use assert() which is far from ideal (I could give
details but I'll skip this for now because I think everybody realizes the
problems with assert() already). The only advantage of the current approach
is that it has no third party dependencies. I'd like to use a header-only
testing framework to preserve this advantage as much as possible while also
getting all the nice features you'd expect from such framework and CATCH is
the best candidate I know of.
Assuming there are no objections to using it, I'd like to add catch.hpp
(https://github.com/philsquared/Catch/blob/master/single_include/catch.hpp)
directly to SOCI repository, e.g. as tests/catch.hpp. I don't think it's
worth the trouble to use a submodule for it, but we could do this too if
people prefer it.
I am less sure about how to handle the transition from assert() to CATCH.
One possibility would be to just globally replace all asserts with
REQUIRE() macros. This would be suboptimal (if only because some of the
asserts should probably be replaced with CHECK(), to allow the tests to
continue if one of them fails), but should be relatively simple to do. And
if we do this, we should probably also move all the files from tests/assert
one directory level up, as the "assert" part wouldn't make any sense any
more.
Another possibility would be to start a parallel tests hierarchy in
tests/catch. I'm not too kin on it, mostly because I don't like duplication
but also because this would require changing the CMake files and I'd rather
avoid this.
Finally, it would be possible to just start using CATCH for the checks
without changing anything in the existing ones. I don't like this one too
much neither because it's going to be confusing to have different macros
used in different places, but it's definitely the simplest one.
What would be the preferred approach? Or maybe someone sees a better one,
not listed above? And, of course, do we have a consensus for using CATCH in
the first place?
Thanks in advance for your thoughts,
VZ