Details
-
Type:
Task
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.1.1
-
Fix Version/s: 1.2 final
-
Component/s: Documentation, Testing
-
Labels:None
Description
The behaviour of method grails.test.MockUtils.mockDomain was changed in release 1.1.1 (possibly caused by fix for issue GRAILS-4495).
A list that is passed as a method parameter does no longer reflect changes (adding/removing of instances) to the mocked domain.
Unit tests that check for addition/removal of domain instances by using the initial list will fail with the current release (see example below).
Some code examples in the Grails reference documentation still propagate this usage pattern (e.g. in chapter 9.1, section 'The Testing Framework') and should be updated.
Example:
class MyServiceTests extends GrailsUnitTestCase {
void testCreateSomething() {
def testInstances = []
mockDomain(Item, testInstances)
//do something, e.g. create a new domain instance
assertEquals 1, testInstances
}
}
Assigning all documentation related issues to 1.2 final since they don't represent a change to the codebase