당신은 당신의 테스트 프레임 워크로 스팍을 사용하는 것이 좋습니다 :
class ExampleWebAppSpecification extends Specification {
def "Should return 200 & a message with the input appended"() {
setup:
def primerEndpoint = new RESTClient('http://localhost:8080/')
when:
def resp = primerEndpoint.get([ path: 'exampleendpoint', query : [ input : 'Get a hair cut' ]])
then:
with(resp) {
status == 200
contentType == "application/json"
}
with(resp.data) {
payload == "Something really important: Get a hair cut"
}
}
}
편집 - buildConfig.groovy에서 :
https://spock-framework.readthedocs.org/en/latest/
예 REST를 위해 그것을 사용하는 방법
compile("org.codehaus.groovy:groovy-all:2.2.0")
compile("com.fasterxml.jackson.core:jackson-databind")
testCompile("org.spockframework:spock-core:0.7-groovy-2.0")
testCompile("org.codehaus.groovy.modules.http-builder:http-builder:0.7+")
testCompile("net.sf.json-lib:json-lib:2.4+")
답장을 보내 주셔서 감사합니다. 설치 한 플러그인 및 플러그인을 알려주십시오. 왜냐하면이 RESTClient 클래스는 기본적으로 사용할 수 없기 때문입니다. – Chetan
buildConfig.groovy :'compile ': rest-client-builder : 2.0.3 "' – roeygol
네, 실제로 이전에 Google을 확인한 후에 그랬습니다. 그러나 아직 많이 찾은 후에도 해결되지 않은 문제가 하나 있는데, buildConfig에 추가하고 설치할 앱을 실행할 때입니다. 그렇다하더라도 그것은 나에게와 오류를 보여줍니다 빨간색 underline-'그루비 : – Chetan