Towards Side Effectless Assert Statements

basleijdekkers

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.

Comments below can no longer be edited.

1 Response to Towards Side Effectless Assert Statements

  1. Showcase Listing says:

    March 3, 2010

    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?

Subscribe

Subscribe for updates