Karate 是否有更好的方法来引用子特性,以便完成此测试?
当运行以下场景时,测试将完成运行,但执行会立即挂起,gradle test命令永远不会完成。cucumber报告没有生成,因此在该点之前挂起 这似乎是由于对不同的场景有2个调用read(),这两个调用都调用了第三个场景。第三个场景引用父上下文来检查当前请求。 当父请求存储在变量中时,测试将挂起。当在离开第三个场景之前清除该变量时,测试将正常完成。因此,有关引用该上下文的内容会在最后挂起测试 这不完整有什么原因吗?我是否遗漏了一些让测试完成的重要代码 我在特殊请求场景的末尾添加了*def currentRequest={},这样可以完成测试,但这看起来像是一个黑客行为 这是顶级测试场景:Karate 是否有更好的方法来引用子特性,以便完成此测试?,karate,Karate,当运行以下场景时,测试将完成运行,但执行会立即挂起,gradle test命令永远不会完成。cucumber报告没有生成,因此在该点之前挂起 这似乎是由于对不同的场景有2个调用read(),这两个调用都调用了第三个场景。第三个场景引用父上下文来检查当前请求。 当父请求存储在变量中时,测试将挂起。当在离开第三个场景之前清除该变量时,测试将正常完成。因此,有关引用该上下文的内容会在最后挂起测试 这不完整有什么原因吗?我是否遗漏了一些让测试完成的重要代码 我在特殊请求场景的末尾添加了*def curr
Scenario: Updates user id
* def user = call read('utils.feature@endpoint=create-user')
* set user.clientAccountId = user.accountNumber + '-test-client-account-id'
* call read('utils.feature@endpoint=update-user') user
* print 'the test is done!'
测试场景在同一utls.feature文件中调用两个不同的场景
utils.feature:
@ignore
Feature: /users
Background:
* url baseUrl
@endpoint=create-user
Scenario: create a standard user for a test
Given path '/create'
* def restMethod = 'post'
* call read('special-request.feature')
When method restMethod
Then status 201
@endpoint=update-user
Scenario: set a user's client account ID
Given path '/update'
* def restMethod = 'put'
* call read('special-request.feature')
When method restMethod
Then status 201
And match response == {"status":"Success", "message":"Update complete"}
这两种util场景都使用不同的参数/请求调用特殊请求特性
特殊要求。功能:
@ignore
Feature: Builds a special
Scenario: special-request
# The next line causes the test to sit for a long time
* def currentRequest = karate.context.parentContext.getRequest()
# Without the below clear of currentRequest, the test never finishes
# We are de-referencing the parent context's request allows test to finish
* def currentRequest = {}
如果没有currentRequest={},这些是我在测试似乎停止之前得到的最后一行输出
12:21:38.816 [ForkJoinPool-1-worker-1] DEBUG com.intuit.karate - response time in milliseconds: 8.48
1 < 201
1 < Content-Type: application/json
{
"status": "Success",
"message": "Update complete"
}
12:21:38.817 [ForkJoinPool-1-worker-1] DEBUG com.jayway.jsonpath.internal.path.CompiledPath - Evaluating path: $
12:21:38.817 [ForkJoinPool-1-worker-1] DEBUG com.jayway.jsonpath.internal.path.CompiledPath - Evaluating path: $
12:21:38.817 [ForkJoinPool-1-worker-1] DEBUG com.jayway.jsonpath.internal.path.CompiledPath - Evaluating path: $
12:21:38.817 [ForkJoinPool-1-worker-1] DEBUG com.jayway.jsonpath.internal.path.CompiledPath - Evaluating path: $
12:21:38.818 [ForkJoinPool-1-worker-1] INFO com.intuit.karate - [print] the test is done!
12:21:38.818 [pool-1-thread-1] DEBUG com.jayway.jsonpath.internal.path.CompiledPath - Evaluating path: $
<==========---> 81% EXECUTING [39s]
12:21:38.816[ForkJoinPool-1-worker-1]DEBUG com.intuit.karate-响应时间(毫秒):8.48
1 < 201
1<内容类型:应用程序/json
{
“状态”:“成功”,
“消息”:“更新完成”
}
12:21:38.817[ForkJoinPool-1-worker-1]调试com.jayway.jsonpath.internal.path.CompiledPath-评估路径:$
12:21:38.817[ForkJoinPool-1-worker-1]调试com.jayway.jsonpath.internal.path.CompiledPath-评估路径:$
12:21:38.817[ForkJoinPool-1-worker-1]调试com.jayway.jsonpath.internal.path.CompiledPath-评估路径:$
12:21:38.817[ForkJoinPool-1-worker-1]调试com.jayway.jsonpath.internal.path.CompiledPath-评估路径:$
12:21:38.818[ForkJoinPool-1-worker-1]INFO.com.intuit.karate-[print]测试完成了!
12:21:38.818[pool-1-thread-1]调试com.jayway.jsonpath.internal.path.CompiledPath-评估路径:$
81%执行[39秒]
使用currentRequest={},测试完成并成功生成cucumber报告,即使没有这一行,我也会这样做。两条注释:
* karate.context.parentContext.getRequest()
哇,这些都是内部API-s,不适合用户使用,我强烈建议将值作为变量传递。所以,如果你在这方面有困难,所有的赌注都是无效的
听起来你在上面有一个空指针(这里没什么奇怪的)
0.9.4中有一个bug,它会在某些边缘情况下导致测试失败,例如您正在做的事情、测试前的生命周期,或者在karate config.js
中导致挂起并行运行程序的失败。您应该在日志中看到一些指示失败的内容,如果没有,请尝试帮助我们复制此问题
这应该在develope
分支中修复,因此如果可以从源代码构建并在本地进行测试,您可以提供帮助。说明如下:
如果您仍然看到问题,请执行以下操作:两条注释:
* karate.context.parentContext.getRequest()
哇,这些都是内部API-s,不适合用户使用,我强烈建议将值作为变量传递。所以,如果你在这方面有困难,所有的赌注都是无效的
听起来你在上面有一个空指针(这里没什么奇怪的)
0.9.4中有一个bug,它会在某些边缘情况下导致测试失败,例如您正在做的事情、测试前的生命周期,或者在karate config.js
中导致挂起并行运行程序的失败。您应该在日志中看到一些指示失败的内容,如果没有,请尝试帮助我们复制此问题
这应该在develope
分支中修复,因此如果可以从源代码构建并在本地进行测试,您可以提供帮助。说明如下:
如果您仍然看到问题,请这样做:我能够通过开发分支重现问题,因此我将在第二天左右提交一个问题。(每当我有时间用它制作一个框架项目时)作为提示,升级到开发分支时,我还遇到了文件未找到问题,该问题可能会出现在示例项目中:src.test.java.org.infoarmor.subscriptionbilling.subscriber.api.karate.feature.subscriber:java.io.FileNotFoundException:/src/test/java/org/infoarmor/subscriptionbilling/subscriber/api/karate/feature/utils.feature(没有这样的文件或目录)我能够重现开发分支的问题,所以我将在第二天左右提交一个问题。(每当我有时间用它做一个框架项目时)作为提示,我在升级到开发分支时也遇到了文件未找到的问题,该问题可能会出现在示例项目中:src.test.java.org.infoarmor.subscriptionbilling.subscriber.api.karate.feature.subscriber:java.io.FileNotFoundException:/src/test/java/org/infoarmor/subscriptionbilling/subscriber/api/karate/feature/utils.fea真(没有这样的文件或目录)