Announcement Announcement Module
No announcement yet.
Turning off Assertions Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Turning off Assertions

    We'd like to use Grails/Groovy assertions in the same way as we can with Java ones, so we can turn on during QA and turn off in production. It appears that Groovy assertions cannot be turned off.

    It this true? If so, can it be changed? I understand about pre and post conditions etc, but I think that not being able to turn off assertions robs them of one of their main uses:to instrument code to trap bugs during testing. You wan to be able to assert complicated checks for testing, but not pay that overhead in production.

    Any hints would be gratefully received.


  • #2
    This doesn't seem possible, sorry. I suggest you raise an issue or discuss it on the Groovy User mailing list (or do both). The workaround is to add your own guards that only execute assertions if they are enabled (which may be based on a system property or something else). An AST transformation could make this cleaner, but that's quite a high-tech solution. Raising the issue on the Groovy User mailing list may result in more concrete suggestions.