Unit testing Grails单元测试不起作用-NoClassDefFoundError:junit/framework/TestCase
我在根据《Grails in Action》一书中的说明创建的用户域上运行测试。下面是测试的代码Unit testing Grails单元测试不起作用-NoClassDefFoundError:junit/framework/TestCase,unit-testing,grails,junit,Unit Testing,Grails,Junit,我在根据《Grails in Action》一书中的说明创建的用户域上运行测试。下面是测试的代码 package com.grailsinaction import grails.test.* class UserIntegrationTests extends GrailsUnitTestCase { void testFirstSaveEver() { def user = new User( userId: 'johnny', password: 'secret
package com.grailsinaction
import grails.test.*
class UserIntegrationTests extends GrailsUnitTestCase {
void testFirstSaveEver() {
def user = new User( userId: 'johnny', password: 'secret',
homepage: 'http://www.johnnylovesblogging.com' )
assertNotNull user.save()
assertNotNull user.id
def foundUser = User.get( user.id )
assertEquals 'joe', foundUser.userId
}
}
我在grails console命令之后在console中运行代码,它引发了一个错误:
java.lang.NoClassDefFoundError:junit/framework/TestCase
我的代码没有使用错误消息中提到的TestCase类。我的依赖项有问题吗?grails默认情况下附带Spock进行测试。这本书谈到朱尼特。您必须更改测试用例以扩展扩展规范,即spock.lang.Specification,并相应地更改断言等。您是如何从控制台内部运行测试的?您需要显示更多stacktrace,最好是包含有用信息的部分。还有,什么版本的Grails?