首页 > 代码库 > robot framework接口测试之一-完整的测试用例
robot framework接口测试之一-完整的测试用例
*** Settings ***Library CollectionsLibrary jsonLibrary requestsLibrary RequestsLibraryLibrary HttpLibrary.HTTP*** Keywords ***登录大风车 [Arguments] ${jpushid} ${loginName} ${password} ${dict} create dictionary Content-Type=application/x-www-form-urlencoded create session api http://dfc-test.sqaproxy.souche.com ${dict} ${data} create dictionary jpushid=${jpushid} loginName=${loginName} password=${password} ${req} Post Request api //rest/account/login data=http://www.mamicode.com/${data} log ${req.status_code} #? log ${req.content} ${reqj} to json ${req.content} #? log ${reqj} ${reqdata} get from dictionary ${reqj} data ${TT} get from dictionary ${reqdata} token ${procode} get from dictionary ${reqdata} provinceCode ${shopcode} get from dictionary ${reqdata} store set global variable ${jpushid} set global variable ${TT} set global variable ${shopcode} set global variable ${procode} ${form} create dictionary Content-Type=application/x-www-form-urlencoded set global variable ${form}MoGet [Arguments] ${apiurl} ${params}==${EMPTY} ${formget} create dictionary Content-Type=application/x-www-form-urlencoded ${proxy} set variable http://127.0.0.0:8888/ set global variable ${formget} create session api http://lol.sqaproxy.souche.com ${formget} ${resget} get request api ${apiurl} params=${params} should be equal as strings ${resget.status_code} 200 log ${resget} ${resj} to json ${resget.content} log ${resj}MoPost [Arguments] ${apiurl} ${type}==${EMPTY} ${pd}==data ${params}==${EMPTY} [Documentation] … … ${proxy} set variable http://127.0.0.0:8888/ ${top} run keyword if "${type}"=="form" create dictionary Content-Type=application/x-www-form-urlencoded ... ELSE create dictionary Content-Type=application/json log abc create session api http://lol.sqaproxy.souche.com ${top} ${res} run keyword if "${pd}" =="data" post request api ${apiurl} data=http://www.mamicode.com/${params} ... ELSE post request api ${apiurl} params=${params} should be equal as strings ${res.status_code} 200 log ${res.status_code} ${resj} to json ${res.content} log ${resj} #set global variable ${type}
1 *** Settings *** 2 Library json 3 Library Collections 4 Library requests 5 Library RequestsLibrary 6 Resource 基础关键字a.robot 7 8 *** Test Cases *** 9 接受联盟10 [Setup] 登录大风车 161a3797c8346bb1fc1 15868498708 a1234567811 ${data} create dictionary _security_token=${TT} msgId=099e06c4b5b44cd2aaf69714c0c09ec412 MoPost //manage/acceptAlly.json form data ${data}13 14 申请联盟15 [Setup] 登录大风车 161a3797c8346bb1fc1 15868498708 a1234567816 ${data} create dictionary shopCode=000055 memo=“您好,申请联盟” _security_token=${TT}17 MoPost //manage/addAlly.json form data ${data}18 19 拒绝联盟20 [Setup] 登录大风车 161a3797c8346bb1fc1 15810001002 a1234567821 ${data} create dictionary msgId=163b8f7ab4314e9cbab85d3790d194cc _security_token=${TT}22 MoPost //manage/denyAlly.json form data ${data}23 24 获取我的盟友列表25 [Setup] 登录大风车 161a3797c8346bb1fc1 15868498702 a1234567826 ${data} create dictionary page=1 pageSize=10 jpushid= 161a3797c8346bb1fc1 _security_token=${TT}27 MoGet //manage/getAllyList.json params=${data}28 29 获取我的筛选盟友列表30 [Setup] 登录大风车 161a3797c8346bb1fc1 15868498702 a1234567831 ${data} create dictionary _security_token=${TT}32 MoGet /manage/getAllyListForSel.json ${data}33 34 供工作台获取联盟角标35 [Setup] 登录大风车 161a3797c8346bb1fc1 15868498702 a1234567836 ${data} create dictionary _security_token=${TT}37 MoGet /manage/getDashboardNum.json ${data}38 39 获取联盟消息列表40 [Setup] 登录大风车 161a3797c8346bb1fc1 15868498702 a1234567841 ${data} create dictionary page=1 pageSize=10 _security_token=${TT}42 MoGet /manage/getMsgList.json ${data}43 44 获取联盟信息45 [Setup] 登录大风车 161a3797c8346bb1fc1 15868498702 a1234567846 ${data} create dictionary _security_token=${TT}47 MoGet /manage/getOverview.json ${data}48 49 获取店铺联盟设置50 [Setup] 登录大风车 161a3797c8346bb1fc1 15868498702 a1234567851 ${data} create dictionary shopCode=${shopcode} _security_token=${TT}52 MoGet /manage/getSetting.json ${data}53 54 获取当前盟友数量55 [Setup] 登录大风车 161a3797c8346bb1fc1 15868498702 a1234567856 ${data} create dictionary shopCode=${shopcode} _security_token=${TT}57 MoGet /manage/isAllyNumValid.json ${data}58 59 搜索盟友60 [Setup] 登录大风车 161a3797c8346bb1fc1 15868498702 a1234567861 ${data} create dictionary pageSize=5 page=1 province=${procode} _security_token=${TT}62 MoGet /manage/searchAlly.json ${data}63 64 解除联盟65 [Setup] 登录大风车 161a3797c8346bb1fc1 15868498704 a1234567866 ${data} create dictionary _security_token=${TT} shopCode=00218767 MoPost /manage/removeAlly.json form data ${data}68 69 联盟设置70 [Setup] 登录大风车 161a3797c8346bb1fc1 15868498704 a1234567871 ${data} create dictionary _security_token=${TT} linkName=4s用例一级 linkPhone=15868498705 shopDesc=哈哈哈哈72 MoPost /manage/setSetting.json form data ${data}
robot framework接口测试之一-完整的测试用例
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。