yasar
yasar

Reputation: 13738

Python unittest sudden quit

Is there a way to make python unittest (I am using 2.6, I have unittest2 available) as soon as an error or fail occured without waiting all tests to finish?

And a bonus question :) Is there a way to order tests. For example, pulling tests that are likely to fail on front?

Upvotes: 4

Views: 153

Answers (1)

Emil Ivanov
Emil Ivanov

Reputation: 37633

Run unittest it with the -f option.

Options:
    -f, --failfast   Stop on first failure

Example: ./auth_test.py -f

Where at the end of auth_test.py you have

if __name__ == '__main__':
    unittest.main()

For ordering - I don't think so. At least not out of the box. You can, however, run only a single test or class.

./auth_test.py MyTestClass # will run all tests in MyTestClass
./auth_test.py MyTestClass.test_my_work # will run only the test_my_work test

Upvotes: 5

Related Questions