dimanche 28 août 2016

One summary for multiple test files using python unittest

I wanna make automated testing for my python project but I'm not sure about the correct way to use unittest module.

All of my test files are currently in one folder and have this format:

import unittest
class SampleTest(unittest.TestCase):
    def testMethod(self):
        # Assertion here
if __name__ == "__main__":
    unittest.main()

Then I run

find ./tests -name "*_test.py" -exec python {} \;

When there are three test files, it outputs

.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
..
----------------------------------------------------------------------
Ran 2 tests in 0.000s

OK
..
----------------------------------------------------------------------
Ran 2 tests in 0.000s

OK

It printed one summary for each test file. So the question is what can I do to make it print only one test summary, eg Ran 5 tests in 0.001s?

Thanks in advance

And I don't want to install any other module

Aucun commentaire:

Enregistrer un commentaire