Grails

mockDomain does not work on given instance list

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Duplicate
  • Affects Version/s: 1.1.1
  • Fix Version/s: 1.2.1
  • Component/s: Testing
  • Labels:
    None

Description

As documented we should be able to check the list size of testInstances after doing a save():

List testInstances = []
mockDomain(MyType, testInstances)
def instance = new MyType()
instance.save()
assertEquals (1, testInstances.size())

Unfortunately the assertion fails because there will be a replacement list created in MockUtils.mockDomain(...). So the saved instances are not added to the given List.

The workaround I use is:

List testInstances = []
mockDomain(MyType, testInstances)
def instance = new MyType()
instance.save()
def checkInstances = MockUtils.TEST_INSTANCES[(MyType)]
assertEquals (1, checkInstances.size())

At least this is a documentation Bug.

Issue Links

Activity

There are no comments yet on this issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: