small medium large xlarge

Back to: All Forums  Grails
10 Apr 2010, 19:50
Todd Miller (3 posts)

I had trouble getting the integration tests at the end of Chapter 6 to work under Grails 1.2.2, however I was able to solve the problem. I’m posting this here to help anyone else who runs across this..

First problem was with the datasource. The DataSource.groovy for the “test” environment was still referring to hsqldb, but there was no appropriate driver for that after we switched it over to MySQL on page 88 in Chapter 5. You can provide the appropriate information to keep using the hsqldb (which makes sense to me when testing, versus persisting test data to an actual database) by modifying the test portion of DataSource.groovy to show as follows:

	test {
		dataSource {
			driverClassName = "org.hsqldb.jdbcDriver"
			username = "sa"
			password = ""
			dbCreate = "update"
			url = "jdbc:hsqldb:mem:testDb"

However, now you’ll get a weird error about “Could not load class type integration” that looks like this:

Error executing script TestApp: java.lang.RuntimeException: Could not load class in test type 'integration'
gant.TargetExecutionException: java.lang.RuntimeException: Could not load class in test type 'integration'
	at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:331)
	at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334)
	at gant.Gant$_dispatch_closure6.doCall(Gant.groovy)

The problem causing this is apparently the “package tekdays” statement at the very top of the TaskServiceTests.groovy file. You must remove that and also add an import of all tekdays classes. A working integration test file will look like this:

import grails.test.*
import tekdays.*

class TaskServiceTests extends GrailsUnitTestCase {
    def taskService
    protected void setUp() {
        new TekUser(fullName:'Tammy Tester',
                    bio:'A test person').save()

    protected void tearDown() {

    void testAddDefaultTasks() {
        def e = new TekEvent(name:'Test Event',
                             city:'TestCity, USA',
                             description:'Test Description',
                             startDate:new Date(),
                             endDate:new Date() + 1)
        assertEquals e.tasks.size(), 6

Hope this helps someone else working through these examples!

02 Aug 2010, 15:45
Wouter van Vliet (1 post)

Thanks a lot! I ran into this problem and your suggestion fixed it for me.

Regards, Wouter

20 Jan 2011, 13:56
Timothy Good (2 posts)


I wanted to remark on the second problem you mention that you fix by getting rid of the package statement and adding the import. I am working with Grails 1.3.6. Its packaging structure has added the ‘package tekdays’ statement to the classes as well as to the directory structure it creates for the project. So when Dave says on page 104 to “move it to the integration test directory: TekDays/test/integration I did just that and it failed as you described because it could not locate the class.

To fix, I simply created this directory TekDays/test/integration/tekdays and moved the TaskServiceTests.groovy into it. At the head of my TaskServiceTests.groovy code I have:

package tekdays import grails.test.*

This seemed to do it for me.

20 Jan 2011, 16:26
Peter Lorent (3 posts)

Just before running this integration test I decided to import the project in SpringSource Tool Suite with the Grails extension. When using Refactor->Move, the class gets moved to the correct package test/integration/tekdays and runs without issues.

28 Aug 2011, 22:57
D.L. Molineu (2 posts)

Hello, I’m having trouble getting this test to run too. I made the changes detailed above, but am still getting the same error:

groovy.lang.MissingMethodException: No signature of method: is applicable for argument types: () values: [] Possible solutions: wait(), any(), wait(long), sleep(long), any(groovy.lang.Closure), isCase(java.lang.Object) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap( at at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall( at at at tekdays.TaskServiceTests.setUp(TaskServiceTests.groovy:10) at junit.framework.TestCase.runBare( at junit.framework.TestResult$1.protect( at junit.framework.TestResult.runProtected( at at at junit.framework.TestSuite.runTest( at at at at at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests( at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests( at at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(

Any idea what I need to do to fix this? Thanks!

29 Aug 2011, 02:52
D.L. Molineu (2 posts)

Alright, dumb mistake on my part, I was running the integration test as a JUnit test (which does work for all of my unit tests). When I ran the integration test using the Run As: “Grails test-app” option it worked.

You must be logged in to comment