I'm staring a toy project with Grails, but I'm having some trouble regarding the HSQLDB database. My DataSource.groovy file is the default one:
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop','update'
url = "jdbc:hsqldb:mem:devDB"
loggingSql = true
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:hsqldb:mem:testDb"
loggingSql = true
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:hsqldb:file:prodDb;shutdown=true"
}
}
}
And I'm running a Simple test:
class BookTests extends GrailsUnitTestCase {
protected void setUp() {
super.setUp()
mockDomain (Book)
def book = new Book ("The shinning","Some guy who wrote it")
if (book.save()){
println ("YEAH")
}
else{
print ("AWWWWHH")
}
}
protected void tearDown() {
super.tearDown()
}
void testSomething() {
def books = Book.getAll()
print (books.size())
}
}
After the book.save()
in the setUp()
method, I get a "YEAH", but in the testSomething()
method, the books.size()
turns out to be 0.
1 test class found in package 'test'
YEAH 0 Process finished with exit code
0
Am I overlooking something? I was under the impression that this HSQLDB was set up for development testing, but I've been having some trouble in both environments (either with this test, or with a very simple app.)