һ
 ¼ע

QQ¼

ֻһٿʼ

Դ ҳ Ѷ
0 ղ 0

ʡ80%ʱ䣬Mockֺ

2022-4-12 15:13| : happy175

Ŵ С

ǰ˵ʹ

Ϊǰˣʹʲôʱ

ÿĵ嶼ˣ̬ҳˡǰֲǼ򵥵ذѺ³ݷŵҳϾˣиǰ˴߼

˽ӿڻûҾ͵ñд߲ǰЧûʵݡ˽ Mock ߣÿӿڶҪԼд Mock ˷Ѷʱѽ

ȵ˺òװѽӿдˣһԽöֶεָ Mock ݶԲϣֵ¸Ĵ롣

ÿһĥ

֣֪طŶӶԸЧʣƫƫ

ϣ

ֱһ죬ҵЧ 100%

ҿʡŵķʽõҪ Mock ݣҪκáңʱĸ˱ǰݶԽ⣬ͳͳˣ

⬇️

Apifox

оһܣԽоԽľ̫ǿȫҵԤڣ硶ǡ޼ǬŲƣһ㣬滹һ㣬ÿһ㶼һƬȫµء

ΪӿʲôǺ˶ˣǰʲôϵݸҾˡ

Ϊдӿĵʲôȫ˷ʱ䣬д߸Ľӿڲ

ֱҲ׺õĹϰܸЧʡ

ڵѾһˡΪܹȫйǰ˳ԱĹЧʶһҲϣڶƪµ㣬ܹúð

ãҪˡ

һ㣺 Mock

Apifox Ǹ API Эߣ Mock ݵĻҲ API ĵ Apifox ά API ɺÿ߽ӿĵҲ Postman һԣ JMeter ԣֱ Mock ݡֻ Mock

ȣҪ Apifox 洴һӿڣݽṹ

ˣ档ɣ

ȻMock أôˣMock Ķд

ľˡ

Apifox Զһص Mock Ҹһ Apifox Զɵ Mock ַ򿪿Ч

Apifox  Mock

ô򵥣ô㣡

ʲôҪã

ʵĴ󲿷 API ݶͨõģûֻšַ䡢ʱȵȵȵȡҪȥд Mock ͺ鷳Ҫôһй

Apifox 棬򵥵飬ȫ޸еġֻҪд API ĵʱѷصݽṹãˡApifox ֶ Mock ݣҪκ

ӿڷصݽṹijֶƽusernameͻõĽϣ

ֶƽphoneͻõ1523782913218907284633

ֶƽcityͻõɹ

ֶƽiconͻ᷵һͼƬ URL򿪾һ png ͼƬ

Ŷʹõ Swagger ߹ API ĵҲԵ뵽 ApifoxApifox ֧ 20 ָʽݵ룬ʱԶһʹ MockһԶ Mock ݡ

ȫòκ Mock õ⣬ֻҪӿڶˣMock ݾˣʲôǰ˴붼д

ڶ㣺Զ Mock

еͬѧʣԤİɣô֪дʲô Mock ʲôã Apifox Mock ܵĵڶ㣺Զ Mock

Apifox һ Mock 򣬵ǵķֶƥеij򣬾ͻݶӦֵMock.js ﷨򣩡

Apifox  Mock

ֶƵƥ䷽ʽ֧ͨʽֶֻҪ url βͻõһȷַ mail ͷͻõһַ

Ҫ time βǻԶֶε Mock ֵstring ͵Ļͷһ 'yyyy-mm-dd hh:mm:ss' ʽʱ䣻integer ͵ĻͷһʱDzǺܣ

ù򣬵ȻͿԶ¹

ǹ˾Ķ id DD ͷʮλ֣ҾͿ½һ string ͵Ĺƥд *orderid mock дһʽ@regexp(/DD\d{10}/)ֻҪκһӿڷֶ orderid βõһ DD1284918414 ķֵ

㣺ֶθ߼

еͬѧ˵DZȽͨõͣһкܶûôͨõͣϼܵij״̬ۡۡϼܣҪô Mock

Apifox 棬ӿڷݽṹʱÿֶζһ߼áĸҳϼ״̬ԶΪö٣öٿѡֵΪavailablesoldpendingӿˣô Mock ͻԶַȡֵ

ֶθ߼

ֶθ߼ﲻֹö٣óȷΧȡֵֶ֣Сֵȡ

JSON Schema ȽĻҲֱд Schemaǿɶռ͸ˡ

Ҫע⣺ʱʵ Mock 򣬶ǽӿڷֵݽṹ壬ǻԽӿڵԵԶУЧģ˽ӿڷصݲãApifox ᷵һݽṹУʧ͸ߺӿڷݽṹԡ

ǵ Mock ҲǸԶɣҪκζá

רͼ

ˬˬֱ˦һŽͼȥˡ

IJ㣺ӿڼԶ Mock

еͬѧ˵һһֳûֶΣݶʵַģ Mock Ҫһʵģֶܿζ尡

ңղʾĶйҵĿͻŷô졣

Ҫضӿһˡ

ѡ Mock

Apifox ӿڶݽṹʱǿԸÿֶ Mock ģֱӾͿѡһϵеij Mock 򣬳ĸʵȫˡҪһҾͿд @nameһ¾ͻõ Larry Smith Susan Lee Ӣ

ǰ˵ Mock 㲻㣬ùͿԸǵù֧ Mock.js ʽֻҪ뵽Ĺȫ Mock ó

Mock ο

Apifox ֧ ģͣSchema 壬ͬĽӿڿԸͬģͣģﶨĹĽӿﶼЧҪκζá

һ Mockܡ

㣺߼ Mock

ôһЩͬѧ˵ϣԼ壺ݲͬIJֵزͬݡ

IJID Ϊ 1 ͷһ۵ijݣID Ϊ 2 ͷһ۵ijݡǰ˿԰Ѽ״̬ҳ涼

ðɣApifox mock ĵΪ׼ġ

Apifox ġӿڹ һ ߼ Mock ǩҳǿӡ

Apifox ߼ Mock

һָijֵʱ򣬾ͷضݡ

趨ҵ1ų۵ģ2ų۳ģ3ųǼ¼ڵģDDD ųǡ ID ʽȷġҰЩֵá

֮ҷ͵1ʱ򣬾ͷһ۵ijϢ2һ۵ģ3һ404 not found4һInvalid Param

ֱģһ˷ˣ

ҾǸ ID ʽȷij

㣺߼ Mock ģ﷨

Mock Ѿdzǿǰɡͷ޼ɣ֪޼ɵǬŲܹм

ǽ߼ Mock дʱ֧ Mock.js ﷨ϻḡһʾ

߼ Mock ﷨ʾ

ʾǽʲôأǿ Apifox ʵһԡ

ʾķؽ

һ JSON ʽ飡

ܹ 20 id ֣ǰҪһݵĶάһξ Mock һףֻҪ̶̼д룡

ǻ﷨ʾ JSON ˴ŰٷֺŰ for 룬 JS ģ﷨Nunjucks﷨ʹɸӵݽṹ

֧ for ѭ֧ if ֧֧ʽֵ֧ú

˵Dzң Apifox͹ˣҪʲô

߲㣺߼ Mock Զű

У

µ Apifox 2.1.7 еǿܡ

°汾ĸ߼ Mock һű Tab߼ Mock Զűʲôõأ

߼ Mock Զű

һʵʵİһѯб GET ӿڣ page pageSizeȡֵ 6 10Ҫбĵ 6 ҳÿҳ޶ 10 ¼Ǹܳķҳ

Ҫ

һ飬ÿһҲһҳһ滹һ page totalҲǵǰҳܼƶ¼һ£ص Mock ݾһϵеijϢ

page ֶΣˣǵ 6 ҳݣҷ page ǵ 10 ҳʲô˼

ҵõ

ٷҳµֳˣղŻܹ 25 ҳأһҳͱܹ 40 ҳˣҵ 10 ҳһҳ 22 ҳ

һҳ

ϣ Mock ʲôأӦǵڼҳݾǵڼҳȻҳӦǹ̶ģΪҷǰͱ䡣

ʱǾҪ߼ Mock Զűˡ

ԶűҲһʾ룬ϸһ¡

  1. ͨ fox.mockResponse.json() ȡϵͳԶɵ JSON ݣֵ responseJson
  2. ͨ fox.mockRequest.getParam('page') ȡʵ pageֵ responseJson page ֶΡ
  3. responseJson total ֶдΪ 120
  4. ͨ fox.mockResponse.setBody(responseJson) ޸ĺı responseJson õ mockResponse 棬޸ϵͳص JSON ݡ

ǵڼҳصľҲǶӦĵڼҳȻҳDZ 12 䣨120 ÿҳ 10

ԶűͿܶˣҪûԱŮ Mock صIJͬͷ񣻻 Mock ڣȻóƴװɶӦ֤ŵȵȣ Mock ݱ˴Ǻϡ

ԶűԲĶ fox.mockRequest fox.mockResponseԻȡHeaderCookie޸Ӧ BodyHTTP ״̬ȣӦʱԶ塣

˵ţţɣ

Ͻȥذ

Apifox Mock ߲ܵݣչ

ǸǰˣҶҾӦùһơ

Apifox Mock ȫֵȥءַwww.apifox.cn

API Mock ȫӵˡ

ǵҪApifoxʹãWEB Ŀǰ֧ Mock ܡ

һ£Mock ֻ Apifox ĹеһС֡Apifox = Postman + Swagger + Mock + JmeterĹԶֹƪЩ

·
·


ʻ
ʻ

0 ˲

Ա

  • RSS
    • ƼѶ>>
    • ơǰ>>
    • ƽ̳(PS…)>>
    • ز(PSDPNGAI…)>>
  • ʼ
  • APP
    ԴAPPͻ

    ɨά
    Android
    IOS
  • ΢
    Դ΢Źƽ̨

    ɨάע
    ӹں: web-tech
̳¡ͼƬѷϴվԭתԻ,µİȨԭ
վַİȨ֪ͨǵĹԱ,Ա(Email:admin@websjy.com)ʱȡȨɾ
ܾκκʽڱ̳л񹲺͹ִ!

QQ| 42011102000510|Archiver|ֻ|Դ-̳ ( ICP19023897-2 )

GMT+8, 2022-4-12 15:13

ض