I try to be a good programmer and set up unit tests for my Grails 2.2.3 application. Unit tests that use the GORM method introduced by .save() are apparently not stored in the test database. For example, here is what consists of one test:
@TestFor(TermService) @Mock(Term) class TermServiceTests { void testTermCount() { def t = new Term(code: "201310").save(validate: false, flush: true, failOnError: true) println "Printing Term: " + t.toString() assert 1 == Term.count()
I made println , which ends printing Printing Term: null , which means that the term has not saved and returned an instance of Term. The first statement is false if Term.count() returns 0.
Does anyone know why this could be? I have a Term and TermService layout (via the TestFor annotation, I believe), so I'm not quite sure why this will not work. Thanks!
Edit: Here is my Term class.
class Term { Integer id String code String description Date startDate Date endDate static mapping = {
source share