小编use*_*671的帖子

Grails3控制器集成测试用例失败:未找到线程绑定请求

只需简单的跟随控制器动作spock集成测试.这是我的测试.

@Integration
@Rollback
class TestControllerSpec extends Specification {

    def setup() {
    }

    def cleanup() {
    }

    void "test something"() {
       setup:
        def c = new TestController()
        c.index()
        expect:
        c.response.contentType !=null
    }
}
Run Code Online (Sandbox Code Playgroud)

获得以下异常

java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside …
Run Code Online (Sandbox Code Playgroud)

grails integration-testing grails-plugin grails-3.0

5
推荐指数
2
解决办法
1345
查看次数