Towards Side Effectless Assert Statements

It is a well known rule that assert statements should cause no changes in state outside of them (aka side effects). Until now, you could only check if this rule was followed by visually inspecting the code. In IntelliJ IDEA 9 a new assert statement with side effects inspection will be available to help you keep assert statements free of side effects.

'assert' has side effects warning

The inspection will warn about modification of variables and fields inside of the assert statement. The assert statement will also be reported if a method called by it modifies any fields.

This entry was posted in New Features and tagged , . Bookmark the permalink.

One Response to Towards Side Effectless Assert Statements

  1. My computer guy can’t seem to get that to work…He just puts the code in there exactly how it is in the picture above?

Leave a Reply

Your email address will not be published. Required fields are marked *