+ 1
What real life situations can assertions be used for?
4 odpowiedzi
+ 3
Simple testing and debugging of course!
For example, you wrote a function that doubles a number, and you want to test it. You may want to write a file with some testcases like
assert f(2) == 4
assert f(0) == 0
and run it every time you change your f() function to make sure that its behaviour hasn't changed.
+ 1
Assertion is used on unit testing of code block. It helps to validate the input and output of a function and raise appropriate exception for negative values.
+ 1
Use it for input test. Also... the simplest way to check how it goes.
+ 1
only used for debugging?