Thank you.
> --
> http://mail.python.org/mailman/listinfo/python-list
You could use Python to unittest a Python module written in C++ I
suppose. I guess that would probably work. I suspect that you would
get better/more accurate/reliable results by writing your tests in C+
+ as well though.
If I had to use python to test C++ code, I'd use the Boost python
library: http://www.boost.org/libs/python/doc/ to expose my C++
classes, and write the unittests in python after importing the wrapped
C++ code.
Note, you did ask if it was possible. Is it advisable? That's another
question.
All the best,
Keir.
Yes, it's quite possible. Some people even do it. ;-) As for examples, take
a look at Python's own test suite. Much of the code it contains actually
tests modules written in C, which is near enough to C++ for our purposes.
For example, consider that the math module is a thin wrapper around bits of
standard C89 math functions. The test_math.py script then exercises that
code.
So, you'll have to wrap your C++ library to make it available in Python
(check out SWIG and/or Boost and/or Python's Extending and Embedding
documentation), then write test cases. For that, look at the unittest and
doctest modules that come with Python as well as the third-party py.test
package.
Skip
Your wrapper module will need the header files from your C++ library and it
will by dynamically linked against the library's .so (or .dll).
Skip
http://cxxtest.sourceforge.net/
unit testing framework successfully (but not heavily).
Hth,
Giles Brown