4

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?

1 Answer 1

5

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
Sign up to request clarification or add additional context in comments.

1 Comment

I am really beginner at unittestig, so I am not familiar with command line usage. I am using it with unittest.main() call. Can you give an example usage?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.