欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Mock 工具charles笔记

程序员文章站 2022-04-22 16:08:22
...
  1. ubuntu 安装charles
    参考链接:
    Ubuntu 18.04安装Charles
  2. 安卓手机(模拟器)使用代理
    注: 安卓7以上的手机使用Charles代理需要修改程序安装包代码.
    使用安卓6手机就不会.
    Mock 工具charles笔记
    这里的IP地址需要是直接的电脑IP地址.
  3. 浏览器使用代理
    浏览器里面导入Charles证书Mock 工具charles笔记
    Mock 工具charles笔记
    浏览器需要安装SwitchyOmega模拟器, 并设置代理模式
    Mock 工具charles笔记
  4. Map Remote模式: 整体测试环境
    使用访问的网址跳转到另外一个去
    Mock 工具charles笔记
  5. Map Rewrite模式: 可以修改指定数据为mock
    Mock 工具charles笔记
    注意: 这里修改的数据一定要和Json返回的数据匹配
  6. Map Local 模式: 可以将指定的Json返回替换为本地的Json 文件.
    Mock 工具charles笔记
  • 获取Json数据. 保存到本地 例如:
vi baseData.json
{"data":{"items":[{"market":{"status_id":8,"region":"CN","status":"休市","time_zone":"Asia/Shanghai","time_zone_desc":null},"quote":{"symbol":"SH600127","code":"600127","exchange":"SH","name":"金健米业","type":11,"sub_type":"ASH","status":1,"current":9.87,"currency":"CNY","percent":10.03,"chg":0.9,"timestamp":1585897200000,"time":1585897200000,"lot_size":100,"tick_size":0.01,"open":8.93,"last_close":8.97,"high":9.87,"low":8.5,"avg_price":9.38,"volume":245177269,"amount":2299663510,"turnover_rate":38.2,"amplitude":15.27,"market_capital":6334400362,"float_market_capital":6334400362,"total_shares":641783218,"float_shares":641783218,"issue_date":894384000000,"lock_set":null,"current_year_percent":146.13,"high52w":9.87,"low52w":3.14,"limit_up":9.87,"limit_down":8.07,"volume_ratio":1.34,"eps":0.02,"pe_ttm":497.881,"pe_forecast":497.881,"pe_lyr":497.881,"navps":1.12,"pb":8.812,"dividend":0,"dividend_yield":0,"profit":12722727.42,"profit_four":12722727.42,"profit_forecast":12722727,"pledge_ratio":null,"goodwill_in_net_assets":null},"tags":[]},{"market":{"status_id":8,"region":"CN","status":"休市","time_zone":"Asia/Shanghai","time_zone_desc":null},"quote":{"symbol":"SH601318","code":"601318","exchange":"SH","name":"中国平安","type":11,"sub_type":"ASH","status":1,"current":68.86,"currency":"CNY","percent":-1.16,"chg":-0.81,"timestamp":1585897200000,"time":1585897200000,"lot_size":100,"tick_size":0.01,"open":69.1,"last_close":69.67,"high":69.26,"low":68.41,"avg_price":68.835,"volume":42025417,"amount":2892833242,"turnover_rate":0.39,"amplitude":1.22,"market_capital":1258777423493,"float_market_capital":745937277332,"total_shares":18280241410,"float_shares":10832664498,"issue_date":1172678400000,"lock_set":null,"current_year_percent":-19.42,"high52w":92.5,"low52w":66,"limit_up":76.64,"limit_down":62.7,"volume_ratio":0.82,"eps":8.17,"pe_ttm":8.425,"pe_forecast":8.425,"pe_lyr":8.425,"navps":36.82,"pb":1.87,"dividend":2.05,"dividend_yield":2.977,"profit":149407000000,"profit_four":149407000000,"profit_forecast":149407000000,"pledge_ratio":3.66,"goodwill_in_net_assets":3.1087659564353847},"tags":[]},{"market":{"status_id":8,"region":"CN","status":"休市","time_zone":"Asia/Shanghai","time_zone_desc":null},"quote":{"symbol":"SZ000002","code":"000002","exchange":"SZ","name":"万科A","type":11,"sub_type":"1","status":1,"current":26.77,"currency":"CNY","percent":-0.41,"chg":-0.11,"timestamp":1585897443000,"time":1585897443000,"lot_size":100,"tick_size":0.01,"open":26.75,"last_close":26.88,"high":27.18,"low":26.6,"avg_price":26.896,"volume":56945280,"amount":1531608324.69,"turnover_rate":0.59,"amplitude":2.16,"market_capital":302558368137,"float_market_capital":260075102051,"total_shares":11302143001,"float_shares":9715170043,"issue_date":665078400000,"lock_set":null,"current_year_percent":-16.81,"high52w":33.6,"low52w":24.18,"limit_up":29.57,"limit_down":24.19,"volume_ratio":0.71,"eps":3.44,"pe_ttm":7.783,"pe_forecast":7.783,"pe_lyr":7.783,"navps":16.64,"pb":1.609,"dividend":1.045,"dividend_yield":3.904,"profit":38872086881.32,"profit_four":38872086881.32,"profit_forecast":38872086881,"pledge_ratio":1.34,"goodwill_in_net_assets":0.11747450616716329},"tags":[]},{"market":{"status_id":8,"region":"CN","status":"休市","time_zone":"Asia/Shanghai","time_zone_desc":null},"quote":{"symbol":"SZ002223","code":"002223","exchange":"SZ","name":"鱼跃医疗","type":11,"sub_type":"2","status":1,"current":40.22,"currency":"CNY","percent":3.79,"chg":1.47,"timestamp":1585897443000,"time":1585897443000,"lot_size":100,"tick_size":0.01,"open":39.3,"last_close":38.75,"high":41.5,"low":38.22,"avg_price":40.13,"volume":148256999,"amount":5949828089.39,"turnover_rate":17.1,"amplitude":8.46,"market_capital":40319622084,"float_market_capital":34864934082,"total_shares":1002476929,"float_shares":866855646,"issue_date":1208448000000,"lock_set":null,"current_year_percent":97.93,"high52w":41.91,"low52w":18.2,"limit_up":42.63,"limit_down":34.88,"volume_ratio":1.24,"eps":0.81,"pe_ttm":49.656,"pe_forecast":42.418,"pe_lyr":55.449,"navps":6.05,"pb":6.648,"dividend":0.15,"dividend_yield":0.373,"profit":727154342.46,"profit_four":811985196.17,"profit_forecast":950536912,"pledge_ratio":18.59,"goodwill_in_net_assets":12.148085307226607},"tags":[]},{"market":{"status_id":8,"region":"CN","status":"休市","time_zone":"Asia/Shanghai","time_zone_desc":null},"quote":{"symbol":"SZ002415","code":"002415","exchange":"SZ","name":"海康威视","type":11,"sub_type":"2","status":1,"current":30.78,"currency":"CNY","percent":1.08,"chg":0.33,"timestamp":1585897443000,"time":1585897443000,"lot_size":100,"tick_size":0.01,"open":30.6,"last_close":30.45,"high":31.12,"low":30.13,"avg_price":30.61,"volume":70059739,"amount":2144867625.12,"turnover_rate":0.87,"amplitude":3.25,"market_capital":287639429223,"float_market_capital":249018582964,"total_shares":9345010696,"float_shares":8090272351,"issue_date":1274976000000,"lock_set":null,"current_year_percent":-5.99,"high52w":40.09,"low52w":23.55,"limit_up":33.5,"limit_down":27.41,"volume_ratio":1.2,"eps":1.28,"pe_ttm":24.001,"pe_forecast":26.874,"pe_lyr":25.336,"navps":4.33,"pb":7.109,"dividend":0.6002218446899036,"dividend_yield":1.95,"profit":11352869241.32,"profit_four":11984400255.45,"profit_forecast":10703112220,"pledge_ratio":9.6,"goodwill_in_net_assets":0.6609504954001856},"tags":[]},{"market":{"status_id":8,"region":"CN","status":"休市","time_zone":"Asia/Shanghai","time_zone_desc":null},"quote":{"symbol":"SZ300526","code":"300526","exchange":"SZ","name":"中潜股份","type":11,"sub_type":"3","status":1,"current":192,"currency":"CNY","percent":-3.83,"chg":-7.64,"timestamp":1585897443000,"time":1585897443000,"lot_size":100,"tick_size":0.01,"open":211.33,"last_close":199.64,"high":219.48,"low":180,"avg_price":196.07,"volume":2001890,"amount":392501705.28,"turnover_rate":1.18,"amplitude":19.78,"market_capital":32766876672,"float_market_capital":32659534272,"total_shares":170660816,"float_shares":170101741,"issue_date":1470067200000,"lock_set":null,"current_year_percent":242.86,"high52w":219.48,"low52w":10.7107,"limit_up":219.6,"limit_down":179.68,"volume_ratio":1.47,"eps":0.13,"pe_ttm":1440.882,"pe_forecast":1191.561,"pe_lyr":1443.554,"navps":3.31,"pb":58.006,"dividend":0.03014,"dividend_yield":0.016,"profit":22698760.39,"profit_four":22740841.99,"profit_forecast":27499112,"pledge_ratio":11.63,"goodwill_in_net_assets":7.75565747243471},"tags":[]}],"items_size":6},"error_code":0,"error_description":""}
  • 制造重复数据
#赋值变量
row=$(cat baseData.json)
#制造data.items, .data.items_size的重复数据
row=$(echo $row|jq '.data.items+=.data.items'|jq '.data.items_size+=.data.items_size')
#重复几次
#保存成文件
echo $row > mockData.json
  1. 弱网测试
    可以看APP在弱网情况下是否稳定, 会不会crash
    Mock 工具charles笔记
相关标签: 学习