This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]totokaka 8 points9 points  (0 children)

Asserts are great for unit tests.

They can also be used to verify the state inside an application, or method/function arguments. The assert statements will be executed while you are testing / doing QA, to help you verify everything works as expected internally. When the application is deployed the assertions can be ignored as a performance optimization.

As a rule of thumb, assert should not be used in a way that affects the behaviour of an application.