Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

trickle down unit tests

If I'm writing a library in C that includes a Python interface, is it OK to just write unit tests for the functions, etc in the Python interface? Assuming the Python interface is complete, it should imply the C code works.

Mostly I'm being lazy in that the Python unit test thing takes almost zero effort to use.

thanks, -nick

like image 716
nick maxwell Avatar asked Mar 07 '26 01:03

nick maxwell


2 Answers

Tests through the Python interface will be valuable acceptance tests for your library. They will not however be unit tests.

Unit tests are written by the same coders, in the same language, on the same platform as the unit which they test. These should be written too!

You're right, though, unit testing in Python is far easier than C++ (or even C, which is what you said!).

like image 188
Johnsyweb Avatar answered Mar 08 '26 13:03

Johnsyweb


If you only care if the Python library works, then test that. This will give you significant confirmation that the C library is robust, but the maxim "if you didn't test it, it doesn't work" still mostly applies and I wouldn't export the library without the test harness.

You could, in theory, test that the processor microcode is doing its job properly but one usually doesn't.

like image 41
msw Avatar answered Mar 08 '26 15:03

msw



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!