[issue18232] running a suite with no tests is not an error

Ezio Melotti report at bugs.python.org
Fri Jul 5 10:21:33 CEST 2013


Ezio Melotti added the comment:

> I'm thinking I'll add a '--min-tests=X' parameter to unittest.main,
> with the semantic that if there are less than X tests executed, the
> test run will be considered a failure,

The minimum number of tests is a fast moving target, and unless you know exactly how many tests you have and use that value, missing tests will be undetected.  If you only want to distinguish between 0 and more tests, a boolean flag is enough, but checking that at least 1 test in the whole test suite is run is quite pointless IMHO (I assume it's quite easy to notice if/when it happens).

Making this per-module or even per-class would be more interesting (because it's harder to spot these problems), but OTOH there's no way to know for sure if this is what the user wants.  A good compromise might be using a boolean flag that generates a warning by using some heuristic (e.g. test discovery found a test_*.py file that defines no tests, or a TestCase class that defines no test_* methods and has no subclasses (or have no subclasses with test_* methods)).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18232>
_______________________________________


More information about the Python-bugs-list mailing list