【发布时间】:2016-01-05 16:10:58
【问题描述】:
当我运行 dredd 时,它似乎只是在第一次 api 调用之后挂起。我不确定如何调试或诊断。我正在使用 dnx web 命令运行 asp.net 5 mvc 6 api 服务。我如何才能看到正在发生的事情或问题可能是什么?
我尝试添加用于调试的钩子,发现它调用了第一个 api,然后就永远不会触发 after 事件。我用邮递员和 curl 测试了 api,结果正确。如果我使用的是 express node.js 服务器,Dredd 也可以使用相同的蓝图。
唯一失败的组合是 Dredd 与 asp.net kestrel 服务器响应。服务器记录发出请求并发送响应,因此它会触发测试,但永远不会完成。
Dredd 是否正在寻找某种后处理钩子,因为我看到服务器使用 dredd 接收请求,而不管 .net 或 node.js。即使我在另一个进程中启动 .net api 进程,它也不起作用,这有什么关系?无论如何,它应该只是对dredd的http请求吧?
它是否关心它从红隼服务器返回?
红隼反应
Content-Type → application/json; charset=utf-8
Date → Wed, 06 Jan 2016 17:14:10 GMT
Server → Kestrel
Transfer-Encoding → chunked
Body {"foo":"bar"}
dredd.yml
dry-run: null
hookfiles: null
language: nodejs
sandbox: false
server: dnx web
server-wait: 3
init: false
names: false
only: []
output: []
header: []
sorted: false
user: null
inline-errors: false
details: false
method: []
color: true
level: verbose
timestamp: false
silent: false
path: []
blueprint: test.apib
endpoint: 'http://localhost:5000'
dredd 命令的控制台输出
Starting server with command: dnx web
Waiting 3 seconds for server command to start...
Hosting environment: Production
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
info: Beginning Dredd testing...
info: Found Hookfiles: hooks.js
hook: before all
hook: before each
info: Microsoft.AspNet.Hosting.Internal.HostingEngine[1]
Request starting HTTP/1.1 GET http://localhost:5000/message
info: Microsoft.AspNet.Mvc.Controllers.ControllerActionInvoker[1]
Executing action method Foo.Controllers.HelloController.Get with arguments () - ModelState is Valid'
info: Microsoft.AspNet.Mvc.Infrastructure.ObjectResultExecutor[1]
Executing ObjectResult, writing value Microsoft.AspNet.Mvc.ActionContext.
info: Microsoft.AspNet.Mvc.Infrastructure.MvcRouteHandler[2]
Executed action Foo.Controllers.HelloController.Get in 0.0165ms
info: Microsoft.AspNet.Hosting.Internal.HostingEngine[2]
Request finished in 0.041ms 200 application/json; charset=utf-8
test.apib
# GET /message
+ Response 200 (application/json; charset=utf-8)
{"foo":"bar"}
【问题讨论】:
-
您介意与我分享您正在使用的 APIBlueprint 吗?
-
当然,我添加了上面的蓝图和更新的更简单的控制台输出。我在node.js express服务器上使用了相同的蓝图,它可以工作......只是关于向dnx .net web api发出请求的事情......它是否正在寻找某种处理钩子,因为我看到服务器接收到要求。即使我在另一个进程中启动了 api 进程,它也不起作用,那有什么关系呢?无论如何,它应该只是对dredd的http请求吧?