Grails 3.3.8:无法解析 ControllerUnitTest

Grails 3.3.8 : Unable to resolve ControllerUnitTest

我正在尝试编写一些基本的控制器测试并遵循文档 https://docs.grails.org/latest/guide/testing.html。我的测试目前无法找到 ControllerUnitTest。是否有我缺少的依赖项?

这是我的导入

grails.testing.web.controllers.ControllerUnitTest

https://github.com/jeffbrown/mcroteaucontrollertest 查看项目。

https://github.com/jeffbrown/mcroteaucontrollertest/blob/master/src/test/groovy/mcroteaucontrollertest/DemoControllerSpec.groovy

package mcroteaucontrollertest

import grails.testing.web.controllers.ControllerUnitTest
import spock.lang.Specification

import static org.springframework.http.HttpStatus.METHOD_NOT_ALLOWED

class DemoControllerSpec extends Specification implements ControllerUnitTest<DemoController> {

    void "test GET request"() {
        when:
        controller.index()

        then:
        response.text == 'Success'
    }

    void "test POST request"() {
        when:
        request.method = 'POST'
        controller.index()

        then:
        response.status == METHOD_NOT_ALLOWED.value()
    }
}

ControllerUnitTest 特征由 grails-web-testing-support 提供。确保你有类似 testCompile "org.grails:grails-web-testing-support" 的内容,如 https://github.com/jeffbrown/mcroteaucontrollertest/blob/cf5f09b1c2efaba759f6513301d7b55fcb29979b/build.gradle#L56.

所示