I am running grails Integration Test cases using command "gradle integrationTest". The test cases run properly but, the process itself doesn't end. This is causing issues in jenkins pipeline where we have to move to next step when the test cases are run.
我正在使用命令“Gradle集成度测试”运行Grails集成测试用例。测试用例运行正常,但过程本身并未结束。这在Jenkins管道中造成了问题,当测试用例运行时,我们必须移动到下一步。
Am I missing out something here? Should I need to provide any other command to terminate the process?
我是不是错过了什么?我是否需要提供任何其他命令来终止该进程?
The below is my code;
以下是我的代码;
package test
import grails.gorm.transactions.Rollback
import grails.testing.mixin.integration.Integration
import grails.testing.spock.OnceBefore
import io.micronaut.core.type.Argument
import io.micronaut.http.HttpRequest
import io.micronaut.http.HttpResponse
import io.micronaut.http.HttpStatus
import io.micronaut.http.client.DefaultHttpClientConfiguration
import io.micronaut.http.client.HttpClient
import io.micronaut.http.client.HttpClientConfiguration
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import spock.lang.Shared
import spock.lang.Specification
import java.time.Duration
@SuppressWarnings(['JUnitPublicNonTestMethod', 'JUnitPublicProperty'])
@Integration
@Rollback
class StatusControllerIntSpec extends Specification {
Logger log = LoggerFactory.getLogger(StatusControllerIntSpec)
@Shared HttpClient client
@OnceBefore
void init() {
String baseUrl = "http://localhost:$serverPort"
HttpClientConfiguration configuration = new DefaultHttpClientConfiguration()
configuration.readTimeout = Duration.ofMinutes(1)
this.client = HttpClient.create(baseUrl.toURL(), configuration)
}
void "Test the index method returns application status"() {
expect:
HttpStatus.OK
when:
HttpRequest request = HttpRequest.GET('/api/status')
.header("SM_USER","XXXX")
HttpResponse<List<Map>> resp = client.toBlocking().exchange(request, Argument.of(List, Map))
then:
resp.status == HttpStatus.OK
resp.body()
resp.body().get(0).get("data").equalsIgnoreCase("Success")
log.info(resp.body().get(0).get("data"))
cleanup:
this.client.close()
this.client.stop()
}
}```
[enter image description here](https://i.stack.imgur.com/O0Sxy.png)
更多回答
优秀答案推荐
我是一名优秀的程序员,十分优秀!