title: Why do I receive "No such property" in before* and after* logic of domain classes in unit tests?
body: <p>I notice that any reference to a property is missing when requiring domain classes in grails unit tests.</p>
  
  <p><strong>Somewhere in the Unit Test</strong></p>
  
  <pre><code>mockDomain(Event)
  
  10.times {
      e   = new Event(eventCalendar:ec, title:"$ec - Event $it", details:"some detail", location:"some location", startDate: now, endDate: now+1)
      e.save()
  }
  </code></pre>
  
  <p><strong>Event.groovy</strong></p>
  
  <pre><code>static beforeInsert = {
      if (!endDate) {
          // do something about it
      }
  }
  </code></pre>
  
  <p><strong>Resulting error</strong></p>
  
  <pre><code>No such property: endDate for class: myproj.Event Possible solutions: endDate
  
  groovy.lang.MissingPropertyException: No such property: endDate for class: myproj.Event
  Possible solutions: endDate
      at myproj.Event$__clinit__closure5.doCall(Event.groovy:74)
      at myproj.Event$__clinit__closure5.doCall(Event.groovy)
      at grails.test.MockUtils.triggerEvent(MockUtils.groovy:724)
      at grails.test.MockUtils$_addDynamicInstanceMethods_closure68.doCall(MockUtils.groovy:752)
      at grails.test.MockUtils$_addDynamicInstanceMethods_closure68.doCall(MockUtils.groovy)
      at myproj.EventCalendarTest$_testCreateAndDeleteCalendarWithEvents_closure1.doCall(EventCalendarTest.groovy:43)
      at myproj.EventCalendarTest.testCreateAndDeleteCalendarWithEvents(EventCalendarTest.groovy:40)
  </code></pre>
  
  <ol>
  <li><strong>How can I still create a working test?</strong></li>
  <li><strong>Why is the stacktrace suggesting the property which it has stated as
  missing?</strong></li>
  </ol>