#60 楼 @seveniruby 师傅 救我
#14 楼 @tspring
就拿这块来说,接口需要的是 int 类型的入参,使用进行 rest 调用时,参数是支持 OBJECT 类型,所以不管传 “1” 或 1 都是可以的,但服务端取值时,是以预先定义好的类型去获取的,在与服务端协定的类型一致的情况下,不管加不加"号都可以的
但是如果在浏览器中 http://localhost:8080/h5Interface/getH5Status?H5PluginId=1&ciPluginId=2’‘ 这么调用,明确给参数传入了字符串,这样是会报错的,但如果服务端是@RequestParam("H5PluginId") Object H5PluginId 这种类型的就无所谓了
@ResponseBody
@RequestMapping(value = "/getH5Status", produces = {"application/json;charset=utf-8"})
public String getH5Status(HttpServletResponse response, HttpSession httpsession,
@RequestParam("H5PluginId") Integer H5PluginId ,@RequestParam("ciPluginId") Integer ciPluginId ) throws Exception {}
given().param("H5PluginId", "1").and().param("ciPluginId", 2)
.get("http://10.168.100.157:8080/h5Interface/getH5Status").getBody().prettyPeek();
#2 楼 @seveniruby 信息不全呀 。。照片、身高、职业、兴趣爱好、交友目的之类的
再考个本科证吧,不管重不重要,这是一种态度,再把相关测试技术沉淀沉淀,虽然辛苦点但是也可以走出自己的一条路的
大家来打王者荣耀吧。。。。。。
又败家。。。
适当换个心情,可以与同事们聊聊明年工作计划、学习计划啊 还有可以梳理自己的目标之类的 在闲的时候 好多事情可以整 啦~~
#7 楼 @chenhengjie123 发现了这个 ,目前还没有尝试 应该可以解决你的这个问题
registerParser
public static void registerParser(String contentType, Parser parser)
Register a custom content-type to be parsed using a predefined parser. E.g. let's say you want parse content-type application/custom with the XML parser to be able to verify the response using the XML dot notations:
get("/x").then().assertThat().body("document.child", equalsTo("something"))..
Since application/custom is not registered to be processed by the XML parser by default you need to explicitly tell REST Assured to use this parser before making the request:
RestAssured.registerParser("application/custom, Parser.XML");
Parameters:
contentType - The content-type to register
parser - The parser to use when verifying the response.
#7 楼 @chenhengjie123 目前没看到有这种属性,这种转换格式的扩展个小方法呗
@ResponseBody
@RequestMapping(value = "/getH5Status", produces = {"application/json;charset=utf-8"})
public String getH5Status(HttpServletResponse response, HttpSession httpsession,
@RequestParam("H5PluginId") Integer H5PluginId ,@RequestParam("ciPluginId") Integer ciPluginId ) throws Exception {}
就拿这种方式来说,服务端对于 “1”、1 这种的传值都是接受的,服务端会自行转换,但是服务端要求的是Integer 当传 “1a”,"1.12" 这种类型的数据来说,肯定是转换失败的。
这和服务端使用的开发语言和框架有关系,这块建议和服务端开发确认一下,如果对于传入不正确的值需要服务端做验证并返回错误原因的,一般情况下需要单独提出这种诉求的。
服务端请求参数要求是 int ,如果传入 string 报错了,可以理解为服务端没做兼容处理,也可以理解为客户端调用不正确
对于服务端测试同学来说,就是为什么不按服务端规范调用,非法调用报错了,是正常现象啊
挺好的这个,我们测试组也自己做了一套,主要用于申请设备,记录设备操作系统、版本、当前拥有人员之类的。
以往我们都是纸制盘点,现在也不需要盘点这个工作了
66666
只要能解决项目中实际的问题 ,自动化就是成功的!
而且自动化刚开始做时,前期可能都存在这些问题,越做越庞大什么都想搞定,但后续过程中都会进行纠正和优化,应该是一个正常的过程
@DoctorQ 你的最爱
#6 楼 @cep 如果你想以 json 格式发送参数 ,使用这种方法
content
@Deprecated
RequestSpecification content(String content)
Deprecated. Use body(String) instead
Specify a String request content (such as e.g. JSON or XML) that'll be sent with the request. This works for the POST, PATCH and PUT methods only. Trying to do this for the other http methods will cause an exception to be thrown.
Example of use:
given().content("{ \"message\" : \"hello world\"}").then().expect().content(equalTo("hello world")).when().post("/json");
This will POST a request containing JSON to "/json" and expect that the response content equals to "hello world".
Note that body(String) and this method are the same except for the syntactic difference.
Parameters:
content - The content to send.
Returns:
The request specification
实践得真知
#42 楼 @abyssalknight 接口返回的 object 本身就不可能是一样的啊,与数据源的比对这也是接口测试必须要做的,rest-assured 适合做什么就看你怎么使用了,你自行封装一套数据源对比方法,你说的这些问题都不是问题
老司机开车啦
#37 楼 @liuhao121 这相当于就是一个方法的使用,报告、参数之类的,从代码层面来说如果有诉求就自行组装就好了
#1 楼 @bruce_liguang 应该可以吧 ,你直接联系这个人就行,他会给你解答的~应该是他们团队~~