Uploaded image for project: 'Grails'
  1. Grails
  2. GRAILS-8898

delete() does not cascade in unit tests

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0.1, 2.2.3, 2.3.9
    • Fix Version/s: None
    • Component/s: Testing
    • Labels:
      None
    • Testcase included:
      yes

      Description

      When using hasMany and belongsTo as described in the documentation Airport/Flights example, it should delete all flights when deleting an airport. However, this does not work in unit tests using the @Mock annotation. We're attaching an example project with the same test case in unit and integration environment, with the first one failing unexpectedly.

        Activity

        Hide
        Malte Huebner added a comment -

        It's the same if you try to removeFromXY(). The instances are removed from the belonging Object but are staying in the persistence context.

        Show
        Malte Huebner added a comment - It's the same if you try to removeFromXY(). The instances are removed from the belonging Object but are staying in the persistence context.
        Hide
        Lari Hotari added a comment -

        There is now HibernateTestMixin for unit tests. See docs at http://grails.org/doc/latest/guide/testing.html#unitTestingDomains .

        Show
        Lari Hotari added a comment - There is now HibernateTestMixin for unit tests. See docs at http://grails.org/doc/latest/guide/testing.html#unitTestingDomains .
        Hide
        Lari Hotari added a comment -

        grails-datastore-test-support dependency is now released. That contains support for HibernateTestMixin and MongoDbTestMixin.

        test "org.grails:grails-datastore-test-support:1.0.1-grails-2.4"
        

        (version for Grails 2.3 is 1.0.1.-grails-2.3)
        supported Hibernate4 plugin version is 4.3.5.5 . Hibernate3 plugin isn't supported for HibernateTestMixin.

        Show
        Lari Hotari added a comment - grails-datastore-test-support dependency is now released. That contains support for HibernateTestMixin and MongoDbTestMixin. test "org.grails:grails-datastore-test-support:1.0.1-grails-2.4" (version for Grails 2.3 is 1.0.1.-grails-2.3) supported Hibernate4 plugin version is 4.3.5.5 . Hibernate3 plugin isn't supported for HibernateTestMixin.

          People

          • Assignee:
            Unassigned
            Reporter:
            Christoph Neuroth
          • Votes:
            6 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:

              Development