I have gone through many source code of functional test cases written in python. Many of the code uses assert for testing equality, why so?
Asked
Active
Viewed 274 times
1 Answers
3
In most test runners, a test failure is indicated by raising an exception - which is what the assert() function does if its argument evaluates to False.
Thus assert(1 == 0) will fail, and abort that specific test with an AssertionError exception. This is caught by the test framework, and the test is marked as having failed.
The framework/test-runner then moves on to the next test.
kdopen
- 8,032
- 7
- 44
- 52