gpt4 book ai didi

unit-testing - 由于错误,无法测试我的 grails 应用程序

转载 作者:行者123 更新时间:2023-12-04 19:14:56 24 4
gpt4 key购买 nike

这是我要测试的域类。

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"
}
}

下面是我的测试课
@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()
}
}

当我尝试使用 test-app 运行我的测试时命令,我有这个错误
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]

我不明白有什么问题。

最佳答案

对于 grails 2.x,您不应扩展 GrailsUnitTestCase,而应使用 mixin 批注。

The Test Mixins

关于unit-testing - 由于错误,无法测试我的 grails 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10773317/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com