これは、spock の ControllerSpec を拡張することにより、コントローラーの単体テストで発生し始めました。spock.lang.Specification を拡張するために元に戻すと、修正されました。
仕様:
package fileupload2
import static org.junit.Assert.assertThat
import static org.hamcrest.core.Is.is
import spock.lang.Specification;
import grails.test.mixin.TestFor
import grails.plugin.spock.ControllerSpec
@TestFor(FileUploadController)
//class FileUploadControllerSpec extends ControllerSpec {
class FileUploadControllerSpec extends Specification {
def "the index should redirect to create" () {
when:
controller.index()
then:
assertThat(response.redirectedUrl, is('/fileUpload/create'))
}
}
カット:
package fileupload2
class FileUploadController {
def fileUploadService
def index() {
redirect (action: "create")
}
def create() {
render(view: 'create')
}
def upload() {
...
}
}
私はこれに約2週間かかっているので、これがバグだとは言いたくない.
UnitSpec の拡張も機能するようです。