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.
For grails 2.x you shouldn’t extend GrailsUnitTestCase, but use the mixin annotations instead.
See The Test Mixins