Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't test my grails application because of error

Here is my domain class, which I want to test.

class TekEvent {
    String city
    String name
    String organizer
    String venue
    Date startDate
    Date endDate
    String description

    static constraints = {
        name()
        city()
        description(maxSize: 5000)
        organizer()
        venue()
        startDate()
        endDate()
    }

    String toString(){
        "$name, $city"
    }
}

And below is my test class

@TestFor(TekEvent)
class TekEventTests extends GrailsUnitTestCase {
    void testToString() {
       def tekEvent = new TekEvent(
               name: 'Groovy One',
               city: 'San Francisco, CA',
               organizer: 'Emil Matevosyan',
               venue: 'Moscone center',
               startDate: new Date('6/2/2015'),
               endDate: new Date('6/5/2015'),
               description: 'This conference will cover all...')

        assertEquals 'Groovy One, San Francisco, CA', tekEvent.toString()
    }
}

When I try to run my test with test-app command , I've got this error

The return type of java.lang.Object mockDomain(java.lang.Class, java.util.List) in tekdays.TekEventTests is incompatible with void mockDomain(java.lang.Class, java.util.List) in grails.test.GrailsUnitTestCase
. At [-1:-1] 

I don't understand what's the problem.

like image 872
emilan Avatar asked May 27 '12 10:05

emilan


1 Answers

For grails 2.x you shouldn't extend GrailsUnitTestCase, but use the mixin annotations instead.

See The Test Mixins

like image 147
Jay Prall Avatar answered Oct 23 '22 13:10

Jay Prall