推荐的测试JSON客户端 - 服务器api的方法是什么? [英] What is the recommended method of testing a JSON client-server api?

查看:118
本文介绍了推荐的测试JSON客户端 - 服务器api的方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑#2:任何人都有一个好的方法来测试客户端 - 服务器应用程序的中间,我们可以拦截请求和响应,根据需要伪造客户端或服务器,并提供api的自我文档?

Edit #2: Does anyone have a good method of testing the "middle" of a client-server application where we can intercept requests and responses, fake the client or server as needed, and which provides self-documentation of the api?

在许多情况下,Cucumber可能是一个很好的解决方案,但它不是我想要的。而这个中间层应该是客户端/服务器实现不可知的。 (例如,黑盒)。

Cucumber might be a good solution in many cases, but it's not quite what I'm looking for. And this middle layer should be client/server implementation agnostic. (e.g., black-box).

我们的客户端 - 服务器模型是一个带有Flex客户端的ruby-on-rails服务器,使用带有JSON的RESTish接口作为数据格式。所以任何客户端发布到服务器通常是一个单一的JSON参数。服务器做它的事情,并以纯JSON模型响应。

Our client-server model is a ruby-on-rails server with a Flex client, using a RESTish interface with JSON as the data format. So anything the client posts to the server is usually a single JSON parameter. The server does it's thing and responds with a pure JSON model.

我们在服务器上进行标准轨测试,我们正在努力在客户端上完成合适的FlexUnit测试(它是一个移动目标)。然而,我们的团队有一个关于当前测试模型的有效性的争论,因为服务器上的每一个变化似乎打破了API的一部分。这告诉我,有一个API通信的问题(团队成员之间,代码中的自我文档等),以及缺乏适当的API健全测试。

We have standard rails testing on the server and we're working on getting proper FlexUnit tests completed on the client (it's a moving target). However, there's a debate in my team about the effectiveness of the current testing model, since every change on the server seems to break part of the API. This is telling me that there is both a problem with API communication (between team members, self-documentation in code, etc..), and a lack of proper API sanity testing.

所以我一直在质疑我们是否需要一个模拟客户端在纯JSON级别测试服务器(没有富客户端的所有其他复杂性)以及可能的模拟服务器,用于与富客户端做同样的事情。这将有两个目的,以记录API并提供API本身的更彻底的测试。

So I've been questioning whether we need to have a mock client for testing the server at a pure JSON level (without all the other complexities of a rich client), and possibly a mock-server for doing the same thing with the rich client. This would serve two purposes, to document the API and to provide more thorough testing of the API itself.

之所以有争论的原因是rails家伙声称rails集成测试足以测试所有的服务器请求,中间测试环境只是冗余。

The reason there's a debate is that the rails guy claims that the rails integration testing is sufficient for testing all the server requests, and the middle-ground testing environment would simply be redundant.

因此,这里的问题是,根据我们的情况,应该如何对自我文档化API进行测试,以及我们应该如何测试API本身?

So the question here is, given our situation, how should be go about self-documenting the API, and how should we test the API itself?

编辑:

我们有像/foo/444/bar.js这样的路由,几乎任何复杂的JSON字符串,取决于操作,例如:

We have routes like /foo/444/bar.js, but the parameters can be virtually any complex JSON string depending on the action, e.g.:

json={
  "foo":{
    "x":1, 
    "y":2
   }, 
  "bar":[1,2,3,4,5]
}

,但除了手动编辑的API文档外,没有自我文档。 rails控制器通常只是反序列化并将更改直接应用到模型。很高兴有共同的测试,告诉我们,当它改变,预期。

but besides manually-edited API docs, there's no self-documentation. The rails controller often just deserializes and applies changes directly to the model. Would be nice to have common tests to tell us when it's changed, and what's expected.

推荐答案

我刚刚开始看这个网络功能测试工具Maxq,我认为它有潜力解决你的问题,Maxq充当您的Web客户端和服务器应用程序之间的代理服务器。
它位于Junit之上,这意味着您可以通过断言对服务器应用程序的调用的行为和响应,为您的API进行适当的单元测试。
它基本上捕获并记录了您从Web客户端发出的所有请求以及从服务器返回的响应,它还能够生成您的请求的测试脚本,您可以使用它来播放和测试任何服务器。

I just started looking at this web functional testing tool called Maxq and I think it has the potential to solve your problem, Maxq acts as a proxy server between your web client and server application. It sits on top of Junit so that means you could do proper unit testing for your API by asserting the behavior and responses of calls to your server app. It basically captures and records all the requests you make from a web client and the responses you get back from a server, it also has the ability to generate test scripts of your request which you could use to play back and test on any server.

您应该尝试 http://maxq.tigris .org /

这篇关于推荐的测试JSON客户端 - 服务器api的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆