Grails - domain objects are not saved in integration test

I follow the example in the book Grails In Action. My integration test fails because searches in the sample code return null references. I used the findAll () call, and now it shows that my test data is not saved; all.size is returned as zero.

void testBasicDynamicFinders() { new User(userId: 'glen', password: 'secret', profile: new Profile(email: ' glen@glensmith.com ')).save() new User(userId: 'peter', password: 'sesame', profile: new Profile(homepage: 'http://www.peter.com/')).save() def all = User.findAll() assertEquals 2, all.size() } 

I tried using save (flush: true) to no avail.

I also included one of the save statements in the try ... catch structure, but an exception does not occur.

Graales really kicks my ass. Please help me?

+4
source share
1 answer

If you use

 save( failOnError:true ) 

Then it should show you any validation errors that prevent the preservation of domain objects :-)

+11
source

Source: https://habr.com/ru/post/1434559/


All Articles