1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740 |
- 2024-11-04 20:25:36 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '{{username}}', 'password': '{{password}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'通过JSONPATH提取数据-TOKEN': {'关键字': 'ex_jsonData', 'EXVALUE': '$..token', 'INDEX': None, 'VARNAME': 'token'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:36 INFO 测试用例名称:能够正确登录用例,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '123456'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:能够正确登录用例,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:能够正确登录用例,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:能够正确登录用例,开始执行步骤3:通过JSONPATH提取数据-TOKEN - {'关键字': 'ex_jsonData', 'EXVALUE': '$..token', 'INDEX': None, 'VARNAME': 'token'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:能够正确登录用例,开始执行步骤4:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:能够正确登录用例,开始执行步骤5:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO -------------------测试用例名称:能够正确登录用例执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:36 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P0] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:36 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:36 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:36 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:36 INFO 用例耗时:0.10566030000000004 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:36 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:36 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '1234562'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '手机号或密码错误!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '1004', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:36 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '1234562'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': '手机号或密码错误!', 'EXPECTED': '手机号或密码错误!', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '1004', 'EXPECTED': '1004', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO -------------------测试用例名称:登录失败-手机号或密码错误用例执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:36 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P1] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:36 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:36 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:36 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:36 INFO 用例耗时:0.08426139999999993 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:36 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:36 INFO -----------------开始执行测试用例:[{'发送Get请求': {'关键字': 'request_get', 'URL': '{{URL}}/user/userInfo', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..username', 'INDEX': 0, 'VARNAME': 'msg_username'}}, {'断言-等于-响应USERNAME': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_username}}', 'EXPECTED': '{{username}}', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:36 INFO 测试用例名称:查看用户信息,开始执行步骤0:发送Get请求 - {'关键字': 'request_get', 'URL': 'http://120.25.127.201:18001//user/userInfo', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5MzYsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxMzYyMzN9.mrpQ6h4-izAgP-HbalIICX7HU8gSPH7xTJkjVrzLJGPv2X5e0mpRRg1-8elFCs_pn8yjdwolXOYALYsb-E1n1Q'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:查看用户信息,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:查看用户信息,开始执行步骤2:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:查看用户信息,开始执行步骤3:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..username', 'INDEX': 0, 'VARNAME': 'msg_username'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:查看用户信息,开始执行步骤4:断言-等于-响应USERNAME - {'关键字': 'assert_text_comparators', 'VALUE': '15096268001', 'EXPECTED': '15096268001', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO -------------------测试用例名称:查看用户信息执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:36 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P2] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:36 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:36 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:36 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:36 INFO 用例耗时:0.09925839999999986 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:36 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:36 INFO -----------------开始执行测试用例:[{'发送Post请求-上传图片': {'关键字': 'request_post_form_data', 'URL': '{{URL}}/file/picUpload', 'FILES': '{"file":open("./files/20240725223321.png","rb")}', 'PARAMS': None, 'HEADERS': None}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}, {'通过JSONPATH提取数据-图片路径': {'关键字': 'ex_jsonData', 'EXVALUE': '$..data', 'INDEX': 0, 'VARNAME': 'msg_data'}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-上传头像,开始执行步骤0:发送Post请求-上传图片 - {'关键字': 'request_post_form_data', 'URL': 'http://120.25.127.201:18001//file/picUpload', 'FILES': '{"file":open("./files/20240725223321.png","rb")}', 'PARAMS': None, 'HEADERS': None} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-上传头像,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-上传头像,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-上传头像,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-上传头像,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-上传头像,开始执行步骤5:通过JSONPATH提取数据-图片路径 - {'关键字': 'ex_jsonData', 'EXVALUE': '$..data', 'INDEX': 0, 'VARNAME': 'msg_data'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO -------------------测试用例名称:修改头像-上传头像执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:36 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P3] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:36 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:36 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:36 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:36 INFO 用例耗时:0.08409670000000014 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:36 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:36 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/updateUserInfo', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'userPhoto': '{{msg_data}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/updateUserInfo', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5MzYsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxMzYyMzN9.mrpQ6h4-izAgP-HbalIICX7HU8gSPH7xTJkjVrzLJGPv2X5e0mpRRg1-8elFCs_pn8yjdwolXOYALYsb-E1n1Q'}, 'DATA': {'userPhoto': '/localPic/2024/11/04/aa51dc43ea3448bb91f269fb9c489aa3.png'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO -------------------测试用例名称:修改头像-确定修改头像执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:36 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P4] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:36 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:36 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:36 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:36 INFO 用例耗时:0.11206969999999972 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:36 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:36 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:36 INFO 测试用例名称:我的书评-发布正常的书评(可能会失败),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:36 INFO -------------------测试用例名称:我的书评-发布正常的书评(可能会失败)执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:37 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P5] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:37 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:37 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADDBEFA0>
- caseinfo = {'_case_name': '我的书评-发布正常的书评(可能会失败)', 'desc': '我的书评-发布正常的书评(可能会失败)', 'featureName': '我的书评', 'process': 'G0--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- extend\keywords.py:183: in ex_mysqlData
- logger.info("数据库查询结果:", rs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
- self._log(INFO, msg, args, **kwargs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
- self.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
- self.callHandlers(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
- hdlr.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
- self.emit(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
- super().emit(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
- self.handleError(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
- msg = self.format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
- return fmt.format(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
- return super().format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
- record.message = record.getMessage()
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
- def getMessage(self):
- """
- Return the message for this LogRecord.
-
- Return the message for this LogRecord after merging any user-supplied
- arguments with the message.
- """
- msg = str(self.msg)
- if self.args:
- > msg = msg % self.args
- E TypeError: not all arguments converted during string formatting
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:37 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:37 INFO 用例耗时:0.24739699999999987 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:37 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:37 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '', 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '书籍ID不存在', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5MzYsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxMzYyMzN9.mrpQ6h4-izAgP-HbalIICX7HU8gSPH7xTJkjVrzLJGPv2X5e0mpRRg1-8elFCs_pn8yjdwolXOYALYsb-E1n1Q'}, 'DATA': {'bookId': '', 'commentContent': 'hami的接口自动化'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': '书籍ID不存在', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:37 INFO -------------------测试用例名称:我的书评-发布不存在的书籍ID(BUG)执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:37 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P6] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:37 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:37 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADDBE520>
- caseinfo = {'_case_name': '我的书评-发布不存在的书籍ID(BUG)', 'desc': '我的书评-发布不存在的书籍ID(BUG)', 'featureName': '我的书评', 'process': 'G0--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <apirun.extend.keywords.KeyWords object at 0x00000215AE0115B0>
- kwargs = {'EXPECTED': '书籍ID不存在', 'OP_STR': '==', 'VALUE': 'SUCCESS', '关键字': 'assert_text_comparators'}
- comparators = {'!=': <function KeyWords.assert_text_comparators.<locals>.<lambda> at 0x00000215ADFDBA60>, '<': <function KeyWords.as...at 0x00000215ADFDB9D0>, '==': <function KeyWords.assert_text_comparators.<locals>.<lambda> at 0x00000215ADFDB8B0>, ...}
- message = None
- @allure.step("参数数据:断言当前文本内容")
- def assert_text_comparators(self, **kwargs):
- """
- 封装断言以进行不同的比较操作。
-
- 参数:
- value (Any): 要比较的值。
- expected (Any): 预期的值。
- op_str (str): 操作符的字符串表示(如 '>', '<', '==' 等)。
- message (str, optional): 自定义的错误消息。
-
- 返回:
- None: 如果断言成功,则不返回任何内容。
-
- 引发:
- AssertionError: 如果断言失败。
- """
- comparators = {
- '>': lambda a, b: a > b,
- '<': lambda a, b: a < b,
- '==': lambda a, b: a == b,
- '>=': lambda a, b: a >= b,
- '<=': lambda a, b: a <= b,
- '!=': lambda a, b: a != b,
- }
-
- message = kwargs.get("MESSAGE", None)
-
- if kwargs["OP_STR"] not in comparators:
- raise ValueError(f"没有该操作方式: {kwargs['OP_STR']}")
-
- if not comparators[kwargs['OP_STR']](kwargs['VALUE'], kwargs["EXPECTED"]):
- if message:
- raise AssertionError(message)
- else:
- > raise AssertionError(f"{kwargs['VALUE']} {kwargs['OP_STR']} {kwargs['EXPECTED']} 失败")
- E AssertionError: SUCCESS == 书籍ID不存在 失败
- extend\keywords.py:228: AssertionError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:37 INFO 异常:<ExceptionInfo AssertionError('SUCCESS == 书籍ID不存在 失败') tblen=31> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:37 INFO 用例耗时:0.11110720000000018 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:37 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:37 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': 118, 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '已评价过该书籍!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '3001', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5MzYsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxMzYyMzN9.mrpQ6h4-izAgP-HbalIICX7HU8gSPH7xTJkjVrzLJGPv2X5e0mpRRg1-8elFCs_pn8yjdwolXOYALYsb-E1n1Q'}, 'DATA': {'bookId': 118, 'commentContent': 'hami的接口自动化'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': '已评价过该书籍!', 'EXPECTED': '已评价过该书籍!', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '3001', 'EXPECTED': '3001', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:37 INFO -------------------测试用例名称:我的书评-发布已评价的数据执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:37 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P7] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:37 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:37 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:37 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:37 INFO 用例耗时:0.09267849999999989 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:37 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:37 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'ham'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布不满五个字的书评(BUG),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:37 INFO -------------------测试用例名称:我的书评-发布不满五个字的书评(BUG)执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:37 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P8] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:37 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:37 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADDBE190>
- caseinfo = {'_case_name': '我的书评-发布不满五个字的书评(BUG)', 'desc': '我的书评-发布不满五个字的书评(BUG)', 'featureName': '我的书评', 'process': 'G0--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- extend\keywords.py:183: in ex_mysqlData
- logger.info("数据库查询结果:", rs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
- self._log(INFO, msg, args, **kwargs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
- self.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
- self.callHandlers(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
- hdlr.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
- self.emit(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
- super().emit(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
- self.handleError(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
- msg = self.format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
- return fmt.format(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
- return super().format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
- record.message = record.getMessage()
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
- def getMessage(self):
- """
- Return the message for this LogRecord.
-
- Return the message for this LogRecord after merging any user-supplied
- arguments with the message.
- """
- msg = str(self.msg)
- if self.args:
- > msg = msg % self.args
- E TypeError: not all arguments converted during string formatting
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:37 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:37 INFO 用例耗时:0.22507089999999996 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:37 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:37 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhahamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamham'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '评价不能超过200字符!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:37 INFO 测试用例名称:我的书评-发布超过200个字的书评,开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO -------------------测试用例名称:我的书评-发布超过200个字的书评执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:38 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P9] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:38 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:38 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADDBE610>
- caseinfo = {'_case_name': '我的书评-发布超过200个字的书评', 'desc': '我的书评-发布超过200个字的书评', 'featureName': '我的书评', 'process': 'G0--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- extend\keywords.py:183: in ex_mysqlData
- logger.info("数据库查询结果:", rs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
- self._log(INFO, msg, args, **kwargs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
- self.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
- self.callHandlers(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
- hdlr.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
- self.emit(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
- super().emit(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
- self.handleError(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
- msg = self.format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
- return fmt.format(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
- return super().format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
- record.message = record.getMessage()
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
- def getMessage(self):
- """
- Return the message for this LogRecord.
-
- Return the message for this LogRecord after merging any user-supplied
- arguments with the message.
- """
- msg = str(self.msg)
- if self.args:
- > msg = msg % self.args
- E TypeError: not all arguments converted during string formatting
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:38 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:38 INFO 用例耗时:0.2116956000000001 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:38 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:38 INFO -----------------开始执行测试用例:[{'发送Get请求': {'关键字': 'request_get', 'URL': '{{URL}}/book/listClickRank', 'PARAMS': None, 'HEADERS': None}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': None, 'VARNAME': 'msg_success'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:38 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤0:发送Get请求 - {'关键字': 'request_get', 'URL': 'http://120.25.127.201:18001//book/listClickRank', 'PARAMS': None, 'HEADERS': None} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': None, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤2:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO -------------------测试用例名称:点击榜单能够显示对应的数据执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:38 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P10] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:38 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:38 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:38 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:38 INFO 用例耗时:0.12249089999999985 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:38 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:38 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hami的接口自动化'}}}, {'JSON断言-等于-响应MSG': {'关键字': 'assert_json_comparators', 'VALUE': '$..msg', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'JSON断言-等于-CODE': {'关键字': 'assert_json_comparators', 'VALUE': '$..code', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:38 INFO 测试用例名称:我的书评-发布正常的书评(优化-直接Josn断言),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO -------------------测试用例名称:我的书评-发布正常的书评(优化-直接Josn断言)执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:38 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P11] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:38 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:38 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADDBE8B0>
- caseinfo = {'_case_name': '我的书评-发布正常的书评(优化-直接Josn断言)', 'desc': '我的书评-发布正常的书评(优化-直接Josn断言)', 'featureName': '我的书评', 'process': 'G0--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- extend\keywords.py:183: in ex_mysqlData
- logger.info("数据库查询结果:", rs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
- self._log(INFO, msg, args, **kwargs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
- self.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
- self.callHandlers(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
- hdlr.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
- self.emit(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
- super().emit(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
- self.handleError(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
- msg = self.format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
- return fmt.format(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
- return super().format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
- record.message = record.getMessage()
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
- def getMessage(self):
- """
- Return the message for this LogRecord.
-
- Return the message for this LogRecord after merging any user-supplied
- arguments with the message.
- """
- msg = str(self.msg)
- if self.args:
- > msg = msg % self.args
- E TypeError: not all arguments converted during string formatting
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:38 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:38 INFO 用例耗时:0.20688920000000044 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:38 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:38 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '{{username}}', 'password': '{{password}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'通过JSONPATH提取数据-TOKEN': {'关键字': 'ex_jsonData', 'EXVALUE': '$..token', 'INDEX': None, 'VARNAME': 'token'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_能够正确登录用例,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '123456'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_能够正确登录用例,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_能够正确登录用例,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_能够正确登录用例,开始执行步骤3:通过JSONPATH提取数据-TOKEN - {'关键字': 'ex_jsonData', 'EXVALUE': '$..token', 'INDEX': None, 'VARNAME': 'token'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_能够正确登录用例,开始执行步骤4:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_能够正确登录用例,开始执行步骤5:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO -------------------测试用例名称:备份_能够正确登录用例执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:38 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P12] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:38 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:38 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:38 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:38 INFO 用例耗时:0.08122730000000011 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:38 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:38 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '1234562'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '手机号或密码错误!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '1004', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_登录失败-手机号或密码错误用例,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '1234562'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_登录失败-手机号或密码错误用例,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_登录失败-手机号或密码错误用例,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_登录失败-手机号或密码错误用例,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': '手机号或密码错误!', 'EXPECTED': '手机号或密码错误!', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_登录失败-手机号或密码错误用例,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '1004', 'EXPECTED': '1004', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO -------------------测试用例名称:备份_登录失败-手机号或密码错误用例执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:38 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P13] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:38 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:38 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:38 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:38 INFO 用例耗时:0.08275990000000011 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:38 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:38 INFO -----------------开始执行测试用例:[{'发送Get请求': {'关键字': 'request_get', 'URL': '{{URL}}/user/userInfo', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..username', 'INDEX': 0, 'VARNAME': 'msg_username'}}, {'断言-等于-响应USERNAME': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_username}}', 'EXPECTED': '{{username}}', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_查看用户信息,开始执行步骤0:发送Get请求 - {'关键字': 'request_get', 'URL': 'http://120.25.127.201:18001//user/userInfo', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5MzgsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxMzg3MTJ9.iLS16XWs6xTMI6mmdU0SWaeOLjMOSXugU_6ZasD5tqy3Uf4rS71m-RvXGmYoRr-sWXkiw2qJIY9e54Bcc6pOVw'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_查看用户信息,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_查看用户信息,开始执行步骤2:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_查看用户信息,开始执行步骤3:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..username', 'INDEX': 0, 'VARNAME': 'msg_username'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_查看用户信息,开始执行步骤4:断言-等于-响应USERNAME - {'关键字': 'assert_text_comparators', 'VALUE': '15096268001', 'EXPECTED': '15096268001', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO -------------------测试用例名称:备份_查看用户信息执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:38 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P14] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:38 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:38 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:38 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:38 INFO 用例耗时:0.08612210000000076 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:38 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:38 INFO -----------------开始执行测试用例:[{'发送Post请求-上传图片': {'关键字': 'request_post_form_data', 'URL': '{{URL}}/file/picUpload', 'FILES': '{"file":open("./files/20240725223321.png","rb")}', 'PARAMS': None, 'HEADERS': None}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}, {'通过JSONPATH提取数据-图片路径': {'关键字': 'ex_jsonData', 'EXVALUE': '$..data', 'INDEX': 0, 'VARNAME': 'msg_data'}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_修改头像-上传头像,开始执行步骤0:发送Post请求-上传图片 - {'关键字': 'request_post_form_data', 'URL': 'http://120.25.127.201:18001//file/picUpload', 'FILES': '{"file":open("./files/20240725223321.png","rb")}', 'PARAMS': None, 'HEADERS': None} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_修改头像-上传头像,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_修改头像-上传头像,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_修改头像-上传头像,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_修改头像-上传头像,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO 测试用例名称:备份_修改头像-上传头像,开始执行步骤5:通过JSONPATH提取数据-图片路径 - {'关键字': 'ex_jsonData', 'EXVALUE': '$..data', 'INDEX': 0, 'VARNAME': 'msg_data'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:38 INFO -------------------测试用例名称:备份_修改头像-上传头像执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:38 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P15] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:38 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:38 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:38 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:38 INFO 用例耗时:0.07912230000000076 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:38 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:39 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/updateUserInfo', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'userPhoto': '{{msg_data}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:39 INFO 测试用例名称:备份_修改头像-确定修改头像,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/updateUserInfo', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5MzgsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxMzg3MTJ9.iLS16XWs6xTMI6mmdU0SWaeOLjMOSXugU_6ZasD5tqy3Uf4rS71m-RvXGmYoRr-sWXkiw2qJIY9e54Bcc6pOVw'}, 'DATA': {'userPhoto': '/localPic/2024/11/04/058a645adf1640e4a9e857d75a4fbb31.png'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:39 INFO 测试用例名称:备份_修改头像-确定修改头像,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:39 INFO 测试用例名称:备份_修改头像-确定修改头像,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:39 INFO 测试用例名称:备份_修改头像-确定修改头像,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:39 INFO 测试用例名称:备份_修改头像-确定修改头像,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:39 INFO -------------------测试用例名称:备份_修改头像-确定修改头像执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:39 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P16] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:39 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:39 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:39 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:39 INFO 用例耗时:0.10777579999999976 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:39 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:39 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布正常的书评(可能会失败),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:39 INFO -------------------测试用例名称:备份_我的书评-发布正常的书评(可能会失败)执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:39 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P17] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:39 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:39 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADE27280>
- caseinfo = {'_case_name': '备份_我的书评-发布正常的书评(可能会失败)', 'desc': '备份_我的书评-发布正常的书评(可能会失败)', 'featureName': '我的书评', 'process': 'G0--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- extend\keywords.py:183: in ex_mysqlData
- logger.info("数据库查询结果:", rs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
- self._log(INFO, msg, args, **kwargs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
- self.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
- self.callHandlers(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
- hdlr.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
- self.emit(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
- super().emit(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
- self.handleError(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
- msg = self.format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
- return fmt.format(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
- return super().format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
- record.message = record.getMessage()
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
- def getMessage(self):
- """
- Return the message for this LogRecord.
-
- Return the message for this LogRecord after merging any user-supplied
- arguments with the message.
- """
- msg = str(self.msg)
- if self.args:
- > msg = msg % self.args
- E TypeError: not all arguments converted during string formatting
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:39 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:39 INFO 用例耗时:0.21631909999999976 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:39 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:39 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '', 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '书籍ID不存在', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布不存在的书籍ID(BUG),开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5MzgsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxMzg3MTJ9.iLS16XWs6xTMI6mmdU0SWaeOLjMOSXugU_6ZasD5tqy3Uf4rS71m-RvXGmYoRr-sWXkiw2qJIY9e54Bcc6pOVw'}, 'DATA': {'bookId': '', 'commentContent': 'hami的接口自动化'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布不存在的书籍ID(BUG),开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布不存在的书籍ID(BUG),开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布不存在的书籍ID(BUG),开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': '书籍ID不存在', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:39 INFO -------------------测试用例名称:备份_我的书评-发布不存在的书籍ID(BUG)执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:39 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P18] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:39 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:39 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADE27DC0>
- caseinfo = {'_case_name': '备份_我的书评-发布不存在的书籍ID(BUG)', 'desc': '备份_我的书评-发布不存在的书籍ID(BUG)', 'featureName': '我的书评', 'process': 'G0--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <apirun.extend.keywords.KeyWords object at 0x00000215ADFD67F0>
- kwargs = {'EXPECTED': '书籍ID不存在', 'OP_STR': '==', 'VALUE': 'SUCCESS', '关键字': 'assert_text_comparators'}
- comparators = {'!=': <function KeyWords.assert_text_comparators.<locals>.<lambda> at 0x00000215ADFCBDC0>, '<': <function KeyWords.as...at 0x00000215ADFCB040>, '==': <function KeyWords.assert_text_comparators.<locals>.<lambda> at 0x00000215ADFCB670>, ...}
- message = None
- @allure.step("参数数据:断言当前文本内容")
- def assert_text_comparators(self, **kwargs):
- """
- 封装断言以进行不同的比较操作。
-
- 参数:
- value (Any): 要比较的值。
- expected (Any): 预期的值。
- op_str (str): 操作符的字符串表示(如 '>', '<', '==' 等)。
- message (str, optional): 自定义的错误消息。
-
- 返回:
- None: 如果断言成功,则不返回任何内容。
-
- 引发:
- AssertionError: 如果断言失败。
- """
- comparators = {
- '>': lambda a, b: a > b,
- '<': lambda a, b: a < b,
- '==': lambda a, b: a == b,
- '>=': lambda a, b: a >= b,
- '<=': lambda a, b: a <= b,
- '!=': lambda a, b: a != b,
- }
-
- message = kwargs.get("MESSAGE", None)
-
- if kwargs["OP_STR"] not in comparators:
- raise ValueError(f"没有该操作方式: {kwargs['OP_STR']}")
-
- if not comparators[kwargs['OP_STR']](kwargs['VALUE'], kwargs["EXPECTED"]):
- if message:
- raise AssertionError(message)
- else:
- > raise AssertionError(f"{kwargs['VALUE']} {kwargs['OP_STR']} {kwargs['EXPECTED']} 失败")
- E AssertionError: SUCCESS == 书籍ID不存在 失败
- extend\keywords.py:228: AssertionError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:39 INFO 异常:<ExceptionInfo AssertionError('SUCCESS == 书籍ID不存在 失败') tblen=31> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:39 INFO 用例耗时:0.11749030000000005 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:39 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:39 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': 118, 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '已评价过该书籍!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '3001', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布已评价的数据,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5MzgsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxMzg3MTJ9.iLS16XWs6xTMI6mmdU0SWaeOLjMOSXugU_6ZasD5tqy3Uf4rS71m-RvXGmYoRr-sWXkiw2qJIY9e54Bcc6pOVw'}, 'DATA': {'bookId': 118, 'commentContent': 'hami的接口自动化'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布已评价的数据,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布已评价的数据,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布已评价的数据,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': '已评价过该书籍!', 'EXPECTED': '已评价过该书籍!', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布已评价的数据,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '3001', 'EXPECTED': '3001', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:39 INFO -------------------测试用例名称:备份_我的书评-发布已评价的数据执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:39 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P19] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:39 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:39 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:39 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:39 INFO 用例耗时:0.10991980000000012 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:39 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:39 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'ham'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布不满五个字的书评(BUG),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:39 INFO -------------------测试用例名称:备份_我的书评-发布不满五个字的书评(BUG)执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:39 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P20] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:39 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:39 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADE27940>
- caseinfo = {'_case_name': '备份_我的书评-发布不满五个字的书评(BUG)', 'desc': '备份_我的书评-发布不满五个字的书评(BUG)', 'featureName': '我的书评', 'process': 'G0--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- extend\keywords.py:183: in ex_mysqlData
- logger.info("数据库查询结果:", rs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
- self._log(INFO, msg, args, **kwargs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
- self.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
- self.callHandlers(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
- hdlr.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
- self.emit(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
- super().emit(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
- self.handleError(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
- msg = self.format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
- return fmt.format(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
- return super().format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
- record.message = record.getMessage()
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
- def getMessage(self):
- """
- Return the message for this LogRecord.
-
- Return the message for this LogRecord after merging any user-supplied
- arguments with the message.
- """
- msg = str(self.msg)
- if self.args:
- > msg = msg % self.args
- E TypeError: not all arguments converted during string formatting
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:39 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:39 INFO 用例耗时:0.20216299999999965 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:39 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:39 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhahamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamham'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '评价不能超过200字符!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:39 INFO 测试用例名称:备份_我的书评-发布超过200个字的书评,开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:40 INFO -------------------测试用例名称:备份_我的书评-发布超过200个字的书评执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:40 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P21] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:40 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:40 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADE27760>
- caseinfo = {'_case_name': '备份_我的书评-发布超过200个字的书评', 'desc': '备份_我的书评-发布超过200个字的书评', 'featureName': '我的书评', 'process': 'G0--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- extend\keywords.py:183: in ex_mysqlData
- logger.info("数据库查询结果:", rs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
- self._log(INFO, msg, args, **kwargs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
- self.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
- self.callHandlers(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
- hdlr.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
- self.emit(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
- super().emit(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
- self.handleError(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
- msg = self.format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
- return fmt.format(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
- return super().format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
- record.message = record.getMessage()
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
- def getMessage(self):
- """
- Return the message for this LogRecord.
-
- Return the message for this LogRecord after merging any user-supplied
- arguments with the message.
- """
- msg = str(self.msg)
- if self.args:
- > msg = msg % self.args
- E TypeError: not all arguments converted during string formatting
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:40 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:40 INFO 用例耗时:0.2145910999999998 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:40 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:40 INFO -----------------开始执行测试用例:[{'发送Get请求': {'关键字': 'request_get', 'URL': '{{URL}}/book/listClickRank', 'PARAMS': None, 'HEADERS': None}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': None, 'VARNAME': 'msg_success'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:40 INFO 测试用例名称:备份_点击榜单能够显示对应的数据,开始执行步骤0:发送Get请求 - {'关键字': 'request_get', 'URL': 'http://120.25.127.201:18001//book/listClickRank', 'PARAMS': None, 'HEADERS': None} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:40 INFO 测试用例名称:备份_点击榜单能够显示对应的数据,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': None, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:40 INFO 测试用例名称:备份_点击榜单能够显示对应的数据,开始执行步骤2:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:40 INFO -------------------测试用例名称:备份_点击榜单能够显示对应的数据执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:40 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P22] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:40 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:40 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:40 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:40 INFO 用例耗时:0.12154480000000056 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:40 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:40 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hami的接口自动化'}}}, {'JSON断言-等于-响应MSG': {'关键字': 'assert_json_comparators', 'VALUE': '$..msg', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'JSON断言-等于-CODE': {'关键字': 'assert_json_comparators', 'VALUE': '$..code', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:40 INFO 测试用例名称:备份_我的书评-发布正常的书评(优化-直接Josn断言),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:40 INFO -------------------测试用例名称:备份_我的书评-发布正常的书评(优化-直接Josn断言)执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:40 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G0--P23] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:40 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:40 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADE27B20>
- caseinfo = {'_case_name': '备份_我的书评-发布正常的书评(优化-直接Josn断言)', 'desc': '备份_我的书评-发布正常的书评(优化-直接Josn断言)', 'featureName': '我的书评', 'process': 'G0--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- extend\keywords.py:183: in ex_mysqlData
- logger.info("数据库查询结果:", rs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
- self._log(INFO, msg, args, **kwargs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
- self.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
- self.callHandlers(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
- hdlr.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
- self.emit(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
- super().emit(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
- self.handleError(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
- msg = self.format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
- return fmt.format(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
- return super().format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
- record.message = record.getMessage()
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
- def getMessage(self):
- """
- Return the message for this LogRecord.
-
- Return the message for this LogRecord after merging any user-supplied
- arguments with the message.
- """
- msg = str(self.msg)
- if self.args:
- > msg = msg % self.args
- E TypeError: not all arguments converted during string formatting
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:40 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:40 INFO 用例耗时:0.2079285999999998 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:40 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:40 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '{{username}}', 'password': '{{password}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'通过JSONPATH提取数据-TOKEN': {'关键字': 'ex_jsonData', 'EXVALUE': '$..token', 'INDEX': None, 'VARNAME': 'token'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:40 INFO 测试用例名称:能够正确登录用例,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '123456'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:40 INFO 测试用例名称:能够正确登录用例,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:40 INFO 测试用例名称:能够正确登录用例,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:40 INFO 测试用例名称:能够正确登录用例,开始执行步骤3:通过JSONPATH提取数据-TOKEN - {'关键字': 'ex_jsonData', 'EXVALUE': '$..token', 'INDEX': None, 'VARNAME': 'token'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:40 INFO 测试用例名称:能够正确登录用例,开始执行步骤4:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:40 INFO 测试用例名称:能够正确登录用例,开始执行步骤5:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:40 INFO -------------------测试用例名称:能够正确登录用例执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:40 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P0] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:40 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:40 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:40 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:40 INFO 用例耗时:0.08391579999999976 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:40 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:40 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '1234562'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '手机号或密码错误!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '1004', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:40 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '1234562'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:40 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:40 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:40 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': '手机号或密码错误!', 'EXPECTED': '手机号或密码错误!', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:40 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '1004', 'EXPECTED': '1004', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:40 INFO -------------------测试用例名称:登录失败-手机号或密码错误用例执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:40 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P1] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:40 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:40 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:40 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:40 INFO 用例耗时:0.08588750000000012 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:40 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:40 INFO -----------------开始执行测试用例:[{'发送Get请求': {'关键字': 'request_get', 'URL': '{{URL}}/user/userInfo', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..username', 'INDEX': 0, 'VARNAME': 'msg_username'}}, {'断言-等于-响应USERNAME': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_username}}', 'EXPECTED': '{{username}}', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:40 INFO 测试用例名称:查看用户信息,开始执行步骤0:发送Get请求 - {'关键字': 'request_get', 'URL': 'http://120.25.127.201:18001//user/userInfo', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDAsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDA4MDd9.SD_JAbmSzzYUHTkOi-Z3eBNl7-3eLJ5-znJJUJgyrm0Bl-vi2HrowFGwpzuBuPZblEJ4XiOMIADyamEEf08QwQ'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO 测试用例名称:查看用户信息,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO 测试用例名称:查看用户信息,开始执行步骤2:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO 测试用例名称:查看用户信息,开始执行步骤3:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..username', 'INDEX': 0, 'VARNAME': 'msg_username'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO 测试用例名称:查看用户信息,开始执行步骤4:断言-等于-响应USERNAME - {'关键字': 'assert_text_comparators', 'VALUE': '15096268001', 'EXPECTED': '15096268001', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO -------------------测试用例名称:查看用户信息执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:41 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P2] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:41 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:41 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:41 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:41 INFO 用例耗时:0.08128289999999971 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:41 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:41 INFO -----------------开始执行测试用例:[{'发送Post请求-上传图片': {'关键字': 'request_post_form_data', 'URL': '{{URL}}/file/picUpload', 'FILES': '{"file":open("./files/20240725223321.png","rb")}', 'PARAMS': None, 'HEADERS': None}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}, {'通过JSONPATH提取数据-图片路径': {'关键字': 'ex_jsonData', 'EXVALUE': '$..data', 'INDEX': 0, 'VARNAME': 'msg_data'}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-上传头像,开始执行步骤0:发送Post请求-上传图片 - {'关键字': 'request_post_form_data', 'URL': 'http://120.25.127.201:18001//file/picUpload', 'FILES': '{"file":open("./files/20240725223321.png","rb")}', 'PARAMS': None, 'HEADERS': None} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-上传头像,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-上传头像,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-上传头像,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-上传头像,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-上传头像,开始执行步骤5:通过JSONPATH提取数据-图片路径 - {'关键字': 'ex_jsonData', 'EXVALUE': '$..data', 'INDEX': 0, 'VARNAME': 'msg_data'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO -------------------测试用例名称:修改头像-上传头像执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:41 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P3] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:41 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:41 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:41 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:41 INFO 用例耗时:0.08287570000000066 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:41 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:41 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/updateUserInfo', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'userPhoto': '{{msg_data}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/updateUserInfo', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDAsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDA4MDd9.SD_JAbmSzzYUHTkOi-Z3eBNl7-3eLJ5-znJJUJgyrm0Bl-vi2HrowFGwpzuBuPZblEJ4XiOMIADyamEEf08QwQ'}, 'DATA': {'userPhoto': '/localPic/2024/11/04/d56a313d79204bd5a200b6604b6af8ac.png'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO -------------------测试用例名称:修改头像-确定修改头像执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:41 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P4] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:41 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:41 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:41 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:41 INFO 用例耗时:0.08997049999999973 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:41 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:41 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布正常的书评(可能会失败),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO -------------------测试用例名称:我的书评-发布正常的书评(可能会失败)执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:41 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P5] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:41 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:41 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADE27100>
- caseinfo = {'_case_name': '我的书评-发布正常的书评(可能会失败)', 'desc': '我的书评-发布正常的书评(可能会失败)', 'featureName': '我的书评', 'process': 'G1--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- extend\keywords.py:183: in ex_mysqlData
- logger.info("数据库查询结果:", rs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
- self._log(INFO, msg, args, **kwargs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
- self.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
- self.callHandlers(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
- hdlr.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
- self.emit(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
- super().emit(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
- self.handleError(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
- msg = self.format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
- return fmt.format(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
- return super().format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
- record.message = record.getMessage()
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
- def getMessage(self):
- """
- Return the message for this LogRecord.
-
- Return the message for this LogRecord after merging any user-supplied
- arguments with the message.
- """
- msg = str(self.msg)
- if self.args:
- > msg = msg % self.args
- E TypeError: not all arguments converted during string formatting
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:41 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:41 INFO 用例耗时:0.2237430000000007 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:41 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:41 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '', 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '书籍ID不存在', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDAsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDA4MDd9.SD_JAbmSzzYUHTkOi-Z3eBNl7-3eLJ5-znJJUJgyrm0Bl-vi2HrowFGwpzuBuPZblEJ4XiOMIADyamEEf08QwQ'}, 'DATA': {'bookId': '', 'commentContent': 'hami的接口自动化'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': '书籍ID不存在', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO -------------------测试用例名称:我的书评-发布不存在的书籍ID(BUG)执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:41 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P6] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:41 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:41 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215AD7ED520>
- caseinfo = {'_case_name': '我的书评-发布不存在的书籍ID(BUG)', 'desc': '我的书评-发布不存在的书籍ID(BUG)', 'featureName': '我的书评', 'process': 'G1--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <apirun.extend.keywords.KeyWords object at 0x00000215ADF63370>
- kwargs = {'EXPECTED': '书籍ID不存在', 'OP_STR': '==', 'VALUE': 'SUCCESS', '关键字': 'assert_text_comparators'}
- comparators = {'!=': <function KeyWords.assert_text_comparators.<locals>.<lambda> at 0x00000215ADF42160>, '<': <function KeyWords.as...at 0x00000215ADF420D0>, '==': <function KeyWords.assert_text_comparators.<locals>.<lambda> at 0x00000215ADFCB280>, ...}
- message = None
- @allure.step("参数数据:断言当前文本内容")
- def assert_text_comparators(self, **kwargs):
- """
- 封装断言以进行不同的比较操作。
-
- 参数:
- value (Any): 要比较的值。
- expected (Any): 预期的值。
- op_str (str): 操作符的字符串表示(如 '>', '<', '==' 等)。
- message (str, optional): 自定义的错误消息。
-
- 返回:
- None: 如果断言成功,则不返回任何内容。
-
- 引发:
- AssertionError: 如果断言失败。
- """
- comparators = {
- '>': lambda a, b: a > b,
- '<': lambda a, b: a < b,
- '==': lambda a, b: a == b,
- '>=': lambda a, b: a >= b,
- '<=': lambda a, b: a <= b,
- '!=': lambda a, b: a != b,
- }
-
- message = kwargs.get("MESSAGE", None)
-
- if kwargs["OP_STR"] not in comparators:
- raise ValueError(f"没有该操作方式: {kwargs['OP_STR']}")
-
- if not comparators[kwargs['OP_STR']](kwargs['VALUE'], kwargs["EXPECTED"]):
- if message:
- raise AssertionError(message)
- else:
- > raise AssertionError(f"{kwargs['VALUE']} {kwargs['OP_STR']} {kwargs['EXPECTED']} 失败")
- E AssertionError: SUCCESS == 书籍ID不存在 失败
- extend\keywords.py:228: AssertionError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:41 INFO 异常:<ExceptionInfo AssertionError('SUCCESS == 书籍ID不存在 失败') tblen=31> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:41 INFO 用例耗时:0.1314056000000008 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:41 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:41 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': 118, 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '已评价过该书籍!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '3001', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDAsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDA4MDd9.SD_JAbmSzzYUHTkOi-Z3eBNl7-3eLJ5-znJJUJgyrm0Bl-vi2HrowFGwpzuBuPZblEJ4XiOMIADyamEEf08QwQ'}, 'DATA': {'bookId': 118, 'commentContent': 'hami的接口自动化'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': '已评价过该书籍!', 'EXPECTED': '已评价过该书籍!', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '3001', 'EXPECTED': '3001', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO -------------------测试用例名称:我的书评-发布已评价的数据执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:41 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P7] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:41 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:41 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:41 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:41 INFO 用例耗时:0.09981740000000006 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:41 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:41 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'ham'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:41 INFO 测试用例名称:我的书评-发布不满五个字的书评(BUG),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:41 INFO -------------------测试用例名称:我的书评-发布不满五个字的书评(BUG)执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:42 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P8] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:42 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:42 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215AD7ED3D0>
- caseinfo = {'_case_name': '我的书评-发布不满五个字的书评(BUG)', 'desc': '我的书评-发布不满五个字的书评(BUG)', 'featureName': '我的书评', 'process': 'G1--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- extend\keywords.py:183: in ex_mysqlData
- logger.info("数据库查询结果:", rs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
- self._log(INFO, msg, args, **kwargs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
- self.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
- self.callHandlers(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
- hdlr.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
- self.emit(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
- super().emit(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
- self.handleError(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
- msg = self.format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
- return fmt.format(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
- return super().format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
- record.message = record.getMessage()
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
- def getMessage(self):
- """
- Return the message for this LogRecord.
-
- Return the message for this LogRecord after merging any user-supplied
- arguments with the message.
- """
- msg = str(self.msg)
- if self.args:
- > msg = msg % self.args
- E TypeError: not all arguments converted during string formatting
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:42 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:42 INFO 用例耗时:0.22421609999999959 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:42 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:42 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhahamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamham'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '评价不能超过200字符!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:42 INFO 测试用例名称:我的书评-发布超过200个字的书评,开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:42 INFO -------------------测试用例名称:我的书评-发布超过200个字的书评执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:42 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P9] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:42 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:42 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADD91130>
- caseinfo = {'_case_name': '我的书评-发布超过200个字的书评', 'desc': '我的书评-发布超过200个字的书评', 'featureName': '我的书评', 'process': 'G1--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- extend\keywords.py:183: in ex_mysqlData
- logger.info("数据库查询结果:", rs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
- self._log(INFO, msg, args, **kwargs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
- self.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
- self.callHandlers(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
- hdlr.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
- self.emit(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
- super().emit(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
- self.handleError(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
- msg = self.format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
- return fmt.format(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
- return super().format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
- record.message = record.getMessage()
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
- def getMessage(self):
- """
- Return the message for this LogRecord.
-
- Return the message for this LogRecord after merging any user-supplied
- arguments with the message.
- """
- msg = str(self.msg)
- if self.args:
- > msg = msg % self.args
- E TypeError: not all arguments converted during string formatting
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:42 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:42 INFO 用例耗时:0.21816670000000027 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:42 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:42 INFO -----------------开始执行测试用例:[{'发送Get请求': {'关键字': 'request_get', 'URL': '{{URL}}/book/listClickRank', 'PARAMS': None, 'HEADERS': None}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': None, 'VARNAME': 'msg_success'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:42 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤0:发送Get请求 - {'关键字': 'request_get', 'URL': 'http://120.25.127.201:18001//book/listClickRank', 'PARAMS': None, 'HEADERS': None} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:42 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': None, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:42 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤2:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:42 INFO -------------------测试用例名称:点击榜单能够显示对应的数据执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:42 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P10] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:42 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:42 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:42 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:42 INFO 用例耗时:0.12021320000000024 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:42 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:42 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hami的接口自动化'}}}, {'JSON断言-等于-响应MSG': {'关键字': 'assert_json_comparators', 'VALUE': '$..msg', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'JSON断言-等于-CODE': {'关键字': 'assert_json_comparators', 'VALUE': '$..code', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:42 INFO 测试用例名称:我的书评-发布正常的书评(优化-直接Josn断言),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:42 INFO -------------------测试用例名称:我的书评-发布正常的书评(优化-直接Josn断言)执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:42 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G1--P11] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:42 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:42 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADD912B0>
- caseinfo = {'_case_name': '我的书评-发布正常的书评(优化-直接Josn断言)', 'desc': '我的书评-发布正常的书评(优化-直接Josn断言)', 'featureName': '我的书评', 'process': 'G1--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- extend\keywords.py:183: in ex_mysqlData
- logger.info("数据库查询结果:", rs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
- self._log(INFO, msg, args, **kwargs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
- self.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
- self.callHandlers(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
- hdlr.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
- self.emit(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
- super().emit(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
- self.handleError(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
- msg = self.format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
- return fmt.format(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
- return super().format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
- record.message = record.getMessage()
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
- def getMessage(self):
- """
- Return the message for this LogRecord.
-
- Return the message for this LogRecord after merging any user-supplied
- arguments with the message.
- """
- msg = str(self.msg)
- if self.args:
- > msg = msg % self.args
- E TypeError: not all arguments converted during string formatting
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:42 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:42 INFO 用例耗时:0.2180433000000006 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:42 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:42 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '{{username}}', 'password': '{{password}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'通过JSONPATH提取数据-TOKEN': {'关键字': 'ex_jsonData', 'EXVALUE': '$..token', 'INDEX': None, 'VARNAME': 'token'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:42 INFO 测试用例名称:能够正确登录用例,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '123456'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:42 INFO 测试用例名称:能够正确登录用例,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:42 INFO 测试用例名称:能够正确登录用例,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:42 INFO 测试用例名称:能够正确登录用例,开始执行步骤3:通过JSONPATH提取数据-TOKEN - {'关键字': 'ex_jsonData', 'EXVALUE': '$..token', 'INDEX': None, 'VARNAME': 'token'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:42 INFO 测试用例名称:能够正确登录用例,开始执行步骤4:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:42 INFO 测试用例名称:能够正确登录用例,开始执行步骤5:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:42 INFO -------------------测试用例名称:能够正确登录用例执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:42 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P0] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:42 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:42 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:42 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:42 INFO 用例耗时:0.08833190000000002 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:42 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:42 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '1234562'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '手机号或密码错误!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '1004', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:42 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '1234562'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': '手机号或密码错误!', 'EXPECTED': '手机号或密码错误!', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '1004', 'EXPECTED': '1004', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO -------------------测试用例名称:登录失败-手机号或密码错误用例执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:43 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P1] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:43 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:43 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:43 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:43 INFO 用例耗时:0.08791390000000021 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:43 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:43 INFO -----------------开始执行测试用例:[{'发送Get请求': {'关键字': 'request_get', 'URL': '{{URL}}/user/userInfo', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..username', 'INDEX': 0, 'VARNAME': 'msg_username'}}, {'断言-等于-响应USERNAME': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_username}}', 'EXPECTED': '{{username}}', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:43 INFO 测试用例名称:查看用户信息,开始执行步骤0:发送Get请求 - {'关键字': 'request_get', 'URL': 'http://120.25.127.201:18001//user/userInfo', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDIsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDI5MzJ9.GuTgz0vBHbVprp8aluVjtGeP5Ezeu2CCImLLPRYhH19N2xgzmvbGeDwDgZZ4Mme20rJnfkpZVpF8ThwY5gGslQ'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:查看用户信息,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:查看用户信息,开始执行步骤2:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:查看用户信息,开始执行步骤3:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..username', 'INDEX': 0, 'VARNAME': 'msg_username'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:查看用户信息,开始执行步骤4:断言-等于-响应USERNAME - {'关键字': 'assert_text_comparators', 'VALUE': '15096268001', 'EXPECTED': '15096268001', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO -------------------测试用例名称:查看用户信息执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:43 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P2] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:43 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:43 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:43 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:43 INFO 用例耗时:0.08571500000000043 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:43 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:43 INFO -----------------开始执行测试用例:[{'发送Post请求-上传图片': {'关键字': 'request_post_form_data', 'URL': '{{URL}}/file/picUpload', 'FILES': '{"file":open("./files/20240725223321.png","rb")}', 'PARAMS': None, 'HEADERS': None}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}, {'通过JSONPATH提取数据-图片路径': {'关键字': 'ex_jsonData', 'EXVALUE': '$..data', 'INDEX': 0, 'VARNAME': 'msg_data'}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-上传头像,开始执行步骤0:发送Post请求-上传图片 - {'关键字': 'request_post_form_data', 'URL': 'http://120.25.127.201:18001//file/picUpload', 'FILES': '{"file":open("./files/20240725223321.png","rb")}', 'PARAMS': None, 'HEADERS': None} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-上传头像,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-上传头像,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-上传头像,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-上传头像,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-上传头像,开始执行步骤5:通过JSONPATH提取数据-图片路径 - {'关键字': 'ex_jsonData', 'EXVALUE': '$..data', 'INDEX': 0, 'VARNAME': 'msg_data'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO -------------------测试用例名称:修改头像-上传头像执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:43 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P3] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:43 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:43 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:43 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:43 INFO 用例耗时:0.08649390000000068 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:43 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:43 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/updateUserInfo', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'userPhoto': '{{msg_data}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/updateUserInfo', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDIsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDI5MzJ9.GuTgz0vBHbVprp8aluVjtGeP5Ezeu2CCImLLPRYhH19N2xgzmvbGeDwDgZZ4Mme20rJnfkpZVpF8ThwY5gGslQ'}, 'DATA': {'userPhoto': '/localPic/2024/11/04/570f407f9a3e466caa6f146b4f9b8af4.png'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO -------------------测试用例名称:修改头像-确定修改头像执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:43 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P4] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:43 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:43 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:43 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:43 INFO 用例耗时:0.09365689999999915 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:43 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:43 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布正常的书评(可能会失败),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO -------------------测试用例名称:我的书评-发布正常的书评(可能会失败)执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:43 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P5] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:43 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:43 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADD91730>
- caseinfo = {'_case_name': '我的书评-发布正常的书评(可能会失败)', 'desc': '我的书评-发布正常的书评(可能会失败)', 'featureName': '我的书评', 'process': 'G3--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- extend\keywords.py:183: in ex_mysqlData
- logger.info("数据库查询结果:", rs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
- self._log(INFO, msg, args, **kwargs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
- self.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
- self.callHandlers(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
- hdlr.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
- self.emit(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
- super().emit(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
- self.handleError(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
- msg = self.format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
- return fmt.format(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
- return super().format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
- record.message = record.getMessage()
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
- def getMessage(self):
- """
- Return the message for this LogRecord.
-
- Return the message for this LogRecord after merging any user-supplied
- arguments with the message.
- """
- msg = str(self.msg)
- if self.args:
- > msg = msg % self.args
- E TypeError: not all arguments converted during string formatting
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:43 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:43 INFO 用例耗时:0.22499270000000138 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:43 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:43 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '', 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '书籍ID不存在', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDIsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDI5MzJ9.GuTgz0vBHbVprp8aluVjtGeP5Ezeu2CCImLLPRYhH19N2xgzmvbGeDwDgZZ4Mme20rJnfkpZVpF8ThwY5gGslQ'}, 'DATA': {'bookId': '', 'commentContent': 'hami的接口自动化'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': '书籍ID不存在', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO -------------------测试用例名称:我的书评-发布不存在的书籍ID(BUG)执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:43 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P6] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:43 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:43 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADD917F0>
- caseinfo = {'_case_name': '我的书评-发布不存在的书籍ID(BUG)', 'desc': '我的书评-发布不存在的书籍ID(BUG)', 'featureName': '我的书评', 'process': 'G3--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <apirun.extend.keywords.KeyWords object at 0x00000215AE0D9490>
- kwargs = {'EXPECTED': '书籍ID不存在', 'OP_STR': '==', 'VALUE': 'SUCCESS', '关键字': 'assert_text_comparators'}
- comparators = {'!=': <function KeyWords.assert_text_comparators.<locals>.<lambda> at 0x00000215ADF675E0>, '<': <function KeyWords.as...at 0x00000215ADF67550>, '==': <function KeyWords.assert_text_comparators.<locals>.<lambda> at 0x00000215ADF67430>, ...}
- message = None
- @allure.step("参数数据:断言当前文本内容")
- def assert_text_comparators(self, **kwargs):
- """
- 封装断言以进行不同的比较操作。
-
- 参数:
- value (Any): 要比较的值。
- expected (Any): 预期的值。
- op_str (str): 操作符的字符串表示(如 '>', '<', '==' 等)。
- message (str, optional): 自定义的错误消息。
-
- 返回:
- None: 如果断言成功,则不返回任何内容。
-
- 引发:
- AssertionError: 如果断言失败。
- """
- comparators = {
- '>': lambda a, b: a > b,
- '<': lambda a, b: a < b,
- '==': lambda a, b: a == b,
- '>=': lambda a, b: a >= b,
- '<=': lambda a, b: a <= b,
- '!=': lambda a, b: a != b,
- }
-
- message = kwargs.get("MESSAGE", None)
-
- if kwargs["OP_STR"] not in comparators:
- raise ValueError(f"没有该操作方式: {kwargs['OP_STR']}")
-
- if not comparators[kwargs['OP_STR']](kwargs['VALUE'], kwargs["EXPECTED"]):
- if message:
- raise AssertionError(message)
- else:
- > raise AssertionError(f"{kwargs['VALUE']} {kwargs['OP_STR']} {kwargs['EXPECTED']} 失败")
- E AssertionError: SUCCESS == 书籍ID不存在 失败
- extend\keywords.py:228: AssertionError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:43 INFO 异常:<ExceptionInfo AssertionError('SUCCESS == 书籍ID不存在 失败') tblen=31> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:43 INFO 用例耗时:0.1124168000000001 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:43 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:43 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': 118, 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '已评价过该书籍!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '3001', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDIsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDI5MzJ9.GuTgz0vBHbVprp8aluVjtGeP5Ezeu2CCImLLPRYhH19N2xgzmvbGeDwDgZZ4Mme20rJnfkpZVpF8ThwY5gGslQ'}, 'DATA': {'bookId': 118, 'commentContent': 'hami的接口自动化'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': '已评价过该书籍!', 'EXPECTED': '已评价过该书籍!', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '3001', 'EXPECTED': '3001', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:43 INFO -------------------测试用例名称:我的书评-发布已评价的数据执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:43 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P7] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:43 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:43 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:43 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:43 INFO 用例耗时:0.09828979999999987 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:43 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:43 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'ham'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:43 INFO 测试用例名称:我的书评-发布不满五个字的书评(BUG),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:44 INFO -------------------测试用例名称:我的书评-发布不满五个字的书评(BUG)执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:44 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P8] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:44 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:44 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADD91970>
- caseinfo = {'_case_name': '我的书评-发布不满五个字的书评(BUG)', 'desc': '我的书评-发布不满五个字的书评(BUG)', 'featureName': '我的书评', 'process': 'G3--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- extend\keywords.py:183: in ex_mysqlData
- logger.info("数据库查询结果:", rs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
- self._log(INFO, msg, args, **kwargs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
- self.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
- self.callHandlers(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
- hdlr.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
- self.emit(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
- super().emit(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
- self.handleError(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
- msg = self.format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
- return fmt.format(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
- return super().format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
- record.message = record.getMessage()
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
- def getMessage(self):
- """
- Return the message for this LogRecord.
-
- Return the message for this LogRecord after merging any user-supplied
- arguments with the message.
- """
- msg = str(self.msg)
- if self.args:
- > msg = msg % self.args
- E TypeError: not all arguments converted during string formatting
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:44 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:44 INFO 用例耗时:0.2153898999999999 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:44 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:44 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhahamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamham'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '评价不能超过200字符!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:44 INFO 测试用例名称:我的书评-发布超过200个字的书评,开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:44 INFO -------------------测试用例名称:我的书评-发布超过200个字的书评执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:44 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P9] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:44 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:44 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADD91A30>
- caseinfo = {'_case_name': '我的书评-发布超过200个字的书评', 'desc': '我的书评-发布超过200个字的书评', 'featureName': '我的书评', 'process': 'G3--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- extend\keywords.py:183: in ex_mysqlData
- logger.info("数据库查询结果:", rs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
- self._log(INFO, msg, args, **kwargs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
- self.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
- self.callHandlers(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
- hdlr.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
- self.emit(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
- super().emit(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
- self.handleError(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
- msg = self.format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
- return fmt.format(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
- return super().format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
- record.message = record.getMessage()
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
- def getMessage(self):
- """
- Return the message for this LogRecord.
-
- Return the message for this LogRecord after merging any user-supplied
- arguments with the message.
- """
- msg = str(self.msg)
- if self.args:
- > msg = msg % self.args
- E TypeError: not all arguments converted during string formatting
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:44 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:44 INFO 用例耗时:0.21632590000000107 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:44 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:44 INFO -----------------开始执行测试用例:[{'发送Get请求': {'关键字': 'request_get', 'URL': '{{URL}}/book/listClickRank', 'PARAMS': None, 'HEADERS': None}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': None, 'VARNAME': 'msg_success'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:44 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤0:发送Get请求 - {'关键字': 'request_get', 'URL': 'http://120.25.127.201:18001//book/listClickRank', 'PARAMS': None, 'HEADERS': None} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:44 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': None, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:44 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤2:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:44 INFO -------------------测试用例名称:点击榜单能够显示对应的数据执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:44 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P10] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:44 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:44 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:44 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:44 INFO 用例耗时:0.10466459999999955 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:44 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:44 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hami的接口自动化'}}}, {'JSON断言-等于-响应MSG': {'关键字': 'assert_json_comparators', 'VALUE': '$..msg', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'JSON断言-等于-CODE': {'关键字': 'assert_json_comparators', 'VALUE': '$..code', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:44 INFO 测试用例名称:我的书评-发布正常的书评(优化-直接Josn断言),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:44 INFO -------------------测试用例名称:我的书评-发布正常的书评(优化-直接Josn断言)执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:44 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G3--P11] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:44 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:44 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADD91BB0>
- caseinfo = {'_case_name': '我的书评-发布正常的书评(优化-直接Josn断言)', 'desc': '我的书评-发布正常的书评(优化-直接Josn断言)', 'featureName': '我的书评', 'process': 'G3--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- extend\keywords.py:183: in ex_mysqlData
- logger.info("数据库查询结果:", rs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
- self._log(INFO, msg, args, **kwargs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
- self.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
- self.callHandlers(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
- hdlr.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
- self.emit(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
- super().emit(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
- self.handleError(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
- msg = self.format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
- return fmt.format(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
- return super().format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
- record.message = record.getMessage()
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
- def getMessage(self):
- """
- Return the message for this LogRecord.
-
- Return the message for this LogRecord after merging any user-supplied
- arguments with the message.
- """
- msg = str(self.msg)
- if self.args:
- > msg = msg % self.args
- E TypeError: not all arguments converted during string formatting
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:44 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:44 INFO 用例耗时:0.21585119999999947 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:44 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:44 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '{{username}}', 'password': '{{password}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'通过JSONPATH提取数据-TOKEN': {'关键字': 'ex_jsonData', 'EXVALUE': '$..token', 'INDEX': None, 'VARNAME': 'token'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:44 INFO 测试用例名称:能够正确登录用例,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '123456'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:能够正确登录用例,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:能够正确登录用例,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:能够正确登录用例,开始执行步骤3:通过JSONPATH提取数据-TOKEN - {'关键字': 'ex_jsonData', 'EXVALUE': '$..token', 'INDEX': None, 'VARNAME': 'token'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:能够正确登录用例,开始执行步骤4:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:能够正确登录用例,开始执行步骤5:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO -------------------测试用例名称:能够正确登录用例执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:45 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P0] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:45 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:45 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:45 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:45 INFO 用例耗时:0.08543449999999986 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:45 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:45 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '1234562'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '手机号或密码错误!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '1004', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:45 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/login', 'PARAMS': None, 'HEADERS': None, 'DATA': {'username': '15096268001', 'password': '1234562'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': '手机号或密码错误!', 'EXPECTED': '手机号或密码错误!', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:登录失败-手机号或密码错误用例,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '1004', 'EXPECTED': '1004', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO -------------------测试用例名称:登录失败-手机号或密码错误用例执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:45 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P1] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:45 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:45 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:45 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:45 INFO 用例耗时:0.09628380000000014 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:45 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:45 INFO -----------------开始执行测试用例:[{'发送Get请求': {'关键字': 'request_get', 'URL': '{{URL}}/user/userInfo', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..username', 'INDEX': 0, 'VARNAME': 'msg_username'}}, {'断言-等于-响应USERNAME': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_username}}', 'EXPECTED': '{{username}}', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:45 INFO 测试用例名称:查看用户信息,开始执行步骤0:发送Get请求 - {'关键字': 'request_get', 'URL': 'http://120.25.127.201:18001//user/userInfo', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDUsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDUwMDh9.p8c93ppTDwsZlGT4rDNGu0okJNH4eq0hioc7SgqQ3XxvUHzIINMm6L6eRqFxjY_Bbi0EP4KMSBgDFZUKiDNF5A'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:查看用户信息,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:查看用户信息,开始执行步骤2:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:查看用户信息,开始执行步骤3:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..username', 'INDEX': 0, 'VARNAME': 'msg_username'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:查看用户信息,开始执行步骤4:断言-等于-响应USERNAME - {'关键字': 'assert_text_comparators', 'VALUE': '15096268001', 'EXPECTED': '15096268001', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO -------------------测试用例名称:查看用户信息执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:45 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P2] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:45 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:45 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:45 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:45 INFO 用例耗时:0.08434860000000022 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:45 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:45 INFO -----------------开始执行测试用例:[{'发送Post请求-上传图片': {'关键字': 'request_post_form_data', 'URL': '{{URL}}/file/picUpload', 'FILES': '{"file":open("./files/20240725223321.png","rb")}', 'PARAMS': None, 'HEADERS': None}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}, {'通过JSONPATH提取数据-图片路径': {'关键字': 'ex_jsonData', 'EXVALUE': '$..data', 'INDEX': 0, 'VARNAME': 'msg_data'}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-上传头像,开始执行步骤0:发送Post请求-上传图片 - {'关键字': 'request_post_form_data', 'URL': 'http://120.25.127.201:18001//file/picUpload', 'FILES': '{"file":open("./files/20240725223321.png","rb")}', 'PARAMS': None, 'HEADERS': None} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-上传头像,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-上传头像,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-上传头像,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-上传头像,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-上传头像,开始执行步骤5:通过JSONPATH提取数据-图片路径 - {'关键字': 'ex_jsonData', 'EXVALUE': '$..data', 'INDEX': 0, 'VARNAME': 'msg_data'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO -------------------测试用例名称:修改头像-上传头像执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:45 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P3] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:45 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:45 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:45 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:45 INFO 用例耗时:0.08542759999999916 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:45 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:45 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/user/updateUserInfo', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'userPhoto': '{{msg_data}}'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//user/updateUserInfo', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDUsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDUwMDh9.p8c93ppTDwsZlGT4rDNGu0okJNH4eq0hioc7SgqQ3XxvUHzIINMm6L6eRqFxjY_Bbi0EP4KMSBgDFZUKiDNF5A'}, 'DATA': {'userPhoto': '/localPic/2024/11/04/23464fa16c494ce7a9e26777e98ccf00.png'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:修改头像-确定修改头像,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '200', 'EXPECTED': '200', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO -------------------测试用例名称:修改头像-确定修改头像执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:45 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P4] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:45 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:45 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:45 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:45 INFO 用例耗时:0.09263550000000009 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:45 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:45 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布正常的书评(可能会失败),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO -------------------测试用例名称:我的书评-发布正常的书评(可能会失败)执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:45 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P5] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:45 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:45 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADD91FD0>
- caseinfo = {'_case_name': '我的书评-发布正常的书评(可能会失败)', 'desc': '我的书评-发布正常的书评(可能会失败)', 'featureName': '我的书评', 'process': 'G2--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- extend\keywords.py:183: in ex_mysqlData
- logger.info("数据库查询结果:", rs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
- self._log(INFO, msg, args, **kwargs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
- self.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
- self.callHandlers(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
- hdlr.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
- self.emit(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
- super().emit(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
- self.handleError(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
- msg = self.format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
- return fmt.format(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
- return super().format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
- record.message = record.getMessage()
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
- def getMessage(self):
- """
- Return the message for this LogRecord.
-
- Return the message for this LogRecord after merging any user-supplied
- arguments with the message.
- """
- msg = str(self.msg)
- if self.args:
- > msg = msg % self.args
- E TypeError: not all arguments converted during string formatting
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:45 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:45 INFO 用例耗时:0.21499640000000042 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:45 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:45 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '', 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '书籍ID不存在', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDUsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDUwMDh9.p8c93ppTDwsZlGT4rDNGu0okJNH4eq0hioc7SgqQ3XxvUHzIINMm6L6eRqFxjY_Bbi0EP4KMSBgDFZUKiDNF5A'}, 'DATA': {'bookId': '', 'commentContent': 'hami的接口自动化'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布不存在的书籍ID(BUG),开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': '书籍ID不存在', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO -------------------测试用例名称:我的书评-发布不存在的书籍ID(BUG)执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:45 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P6] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:45 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:45 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADC8DFA0>
- caseinfo = {'_case_name': '我的书评-发布不存在的书籍ID(BUG)', 'desc': '我的书评-发布不存在的书籍ID(BUG)', 'featureName': '我的书评', 'process': 'G2--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <apirun.extend.keywords.KeyWords object at 0x00000215ADFEA310>
- kwargs = {'EXPECTED': '书籍ID不存在', 'OP_STR': '==', 'VALUE': 'SUCCESS', '关键字': 'assert_text_comparators'}
- comparators = {'!=': <function KeyWords.assert_text_comparators.<locals>.<lambda> at 0x00000215AE0B3430>, '<': <function KeyWords.as...at 0x00000215AE0B33A0>, '==': <function KeyWords.assert_text_comparators.<locals>.<lambda> at 0x00000215AE0B3700>, ...}
- message = None
- @allure.step("参数数据:断言当前文本内容")
- def assert_text_comparators(self, **kwargs):
- """
- 封装断言以进行不同的比较操作。
-
- 参数:
- value (Any): 要比较的值。
- expected (Any): 预期的值。
- op_str (str): 操作符的字符串表示(如 '>', '<', '==' 等)。
- message (str, optional): 自定义的错误消息。
-
- 返回:
- None: 如果断言成功,则不返回任何内容。
-
- 引发:
- AssertionError: 如果断言失败。
- """
- comparators = {
- '>': lambda a, b: a > b,
- '<': lambda a, b: a < b,
- '==': lambda a, b: a == b,
- '>=': lambda a, b: a >= b,
- '<=': lambda a, b: a <= b,
- '!=': lambda a, b: a != b,
- }
-
- message = kwargs.get("MESSAGE", None)
-
- if kwargs["OP_STR"] not in comparators:
- raise ValueError(f"没有该操作方式: {kwargs['OP_STR']}")
-
- if not comparators[kwargs['OP_STR']](kwargs['VALUE'], kwargs["EXPECTED"]):
- if message:
- raise AssertionError(message)
- else:
- > raise AssertionError(f"{kwargs['VALUE']} {kwargs['OP_STR']} {kwargs['EXPECTED']} 失败")
- E AssertionError: SUCCESS == 书籍ID不存在 失败
- extend\keywords.py:228: AssertionError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:45 INFO 异常:<ExceptionInfo AssertionError('SUCCESS == 书籍ID不存在 失败') tblen=31> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:45 INFO 用例耗时:0.11337829999999904 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:45 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:45 INFO -----------------开始执行测试用例:[{'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': 118, 'commentContent': 'hami的接口自动化'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '已评价过该书籍!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '3001', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤0:发送Post请求 - {'关键字': 'request_post_form_urlencoded', 'URL': 'http://120.25.127.201:18001//book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MzEzMjc5NDUsInN1YiI6IntcImlkXCI6MTc5MTA1NjM4NjYzOTg3MjAwMCxcInVzZXJuYW1lXCI6XCIxNTA5NjI2ODAwMVwiLFwibmlja05hbWVcIjpcIuS4gOS6jOS4iVwifSIsImNyZWF0ZWQiOjE3MzA3MjMxNDUwMDh9.p8c93ppTDwsZlGT4rDNGu0okJNH4eq0hioc7SgqQ3XxvUHzIINMm6L6eRqFxjY_Bbi0EP4KMSBgDFZUKiDNF5A'}, 'DATA': {'bookId': 118, 'commentContent': 'hami的接口自动化'}} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤2:通过JSONPATH提取数据-Code - {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤3:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': '已评价过该书籍!', 'EXPECTED': '已评价过该书籍!', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布已评价的数据,开始执行步骤4:断言-等于-CODE - {'关键字': 'assert_text_comparators', 'VALUE': '3001', 'EXPECTED': '3001', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:45 INFO -------------------测试用例名称:我的书评-发布已评价的数据执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:45 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P7] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:45 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:45 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:45 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:45 INFO 用例耗时:0.09990250000000067 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:45 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:45 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'ham'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:45 INFO 测试用例名称:我的书评-发布不满五个字的书评(BUG),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:46 INFO -------------------测试用例名称:我的书评-发布不满五个字的书评(BUG)执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:46 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P8] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:46 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:46 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADC4B100>
- caseinfo = {'_case_name': '我的书评-发布不满五个字的书评(BUG)', 'desc': '我的书评-发布不满五个字的书评(BUG)', 'featureName': '我的书评', 'process': 'G2--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- extend\keywords.py:183: in ex_mysqlData
- logger.info("数据库查询结果:", rs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
- self._log(INFO, msg, args, **kwargs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
- self.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
- self.callHandlers(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
- hdlr.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
- self.emit(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
- super().emit(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
- self.handleError(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
- msg = self.format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
- return fmt.format(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
- return super().format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
- record.message = record.getMessage()
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
- def getMessage(self):
- """
- Return the message for this LogRecord.
-
- Return the message for this LogRecord after merging any user-supplied
- arguments with the message.
- """
- msg = str(self.msg)
- if self.args:
- > msg = msg % self.args
- E TypeError: not all arguments converted during string formatting
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:46 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:46 INFO 用例耗时:0.1959156999999987 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:46 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:46 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhahamhamhamhamhamhamhamhamhamhamhamhamhamhamhamhamham'}}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': 0, 'VARNAME': 'msg_success'}}, {'通过JSONPATH提取数据-Code': {'关键字': 'ex_jsonData', 'EXVALUE': '$..code', 'INDEX': 0, 'VARNAME': 'msg_code'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': '评价不能超过200字符!', 'OP_STR': '=='}}, {'断言-等于-CODE': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_code}}', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:46 INFO 测试用例名称:我的书评-发布超过200个字的书评,开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:46 INFO -------------------测试用例名称:我的书评-发布超过200个字的书评执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:46 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P9] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:46 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:46 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADCB21F0>
- caseinfo = {'_case_name': '我的书评-发布超过200个字的书评', 'desc': '我的书评-发布超过200个字的书评', 'featureName': '我的书评', 'process': 'G2--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- extend\keywords.py:183: in ex_mysqlData
- logger.info("数据库查询结果:", rs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
- self._log(INFO, msg, args, **kwargs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
- self.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
- self.callHandlers(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
- hdlr.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
- self.emit(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
- super().emit(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
- self.handleError(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
- msg = self.format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
- return fmt.format(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
- return super().format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
- record.message = record.getMessage()
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
- def getMessage(self):
- """
- Return the message for this LogRecord.
-
- Return the message for this LogRecord after merging any user-supplied
- arguments with the message.
- """
- msg = str(self.msg)
- if self.args:
- > msg = msg % self.args
- E TypeError: not all arguments converted during string formatting
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:46 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:46 INFO 用例耗时:0.20920360000000038 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:46 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:46 INFO -----------------开始执行测试用例:[{'发送Get请求': {'关键字': 'request_get', 'URL': '{{URL}}/book/listClickRank', 'PARAMS': None, 'HEADERS': None}}, {'通过JSONPATH提取数据-MSG': {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': None, 'VARNAME': 'msg_success'}}, {'断言-等于-响应MSG': {'关键字': 'assert_text_comparators', 'VALUE': '{{msg_success}}', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:46 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤0:发送Get请求 - {'关键字': 'request_get', 'URL': 'http://120.25.127.201:18001//book/listClickRank', 'PARAMS': None, 'HEADERS': None} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:46 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤1:通过JSONPATH提取数据-MSG - {'关键字': 'ex_jsonData', 'EXVALUE': '$..msg', 'INDEX': None, 'VARNAME': 'msg_success'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:46 INFO 测试用例名称:点击榜单能够显示对应的数据,开始执行步骤2:断言-等于-响应MSG - {'关键字': 'assert_text_comparators', 'VALUE': 'SUCCESS', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:46 INFO -------------------测试用例名称:点击榜单能够显示对应的数据执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:46 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P10] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:46 INFO 测试结果:passed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:46 INFO 故障表示:None conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:46 INFO 异常:None conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:46 INFO 用例耗时:0.11341100000000104 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:46 INFO ************************************** conftest.py pytest_runtest_makereport 73
- 2024-11-04 20:25:46 INFO -----------------开始执行测试用例:[{'提取评价的书籍ID': {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'}}, {'发送Post请求': {'关键字': 'request_post_form_urlencoded', 'URL': '{{URL}}/book/addBookComment', 'PARAMS': None, 'HEADERS': {'Authorization': '{{token}}'}, 'DATA': {'bookId': '{{id_1}}', 'commentContent': 'hami的接口自动化'}}}, {'JSON断言-等于-响应MSG': {'关键字': 'assert_json_comparators', 'VALUE': '$..msg', 'EXPECTED': 'SUCCESS', 'OP_STR': '=='}}, {'JSON断言-等于-CODE': {'关键字': 'assert_json_comparators', 'VALUE': '$..code', 'EXPECTED': '200', 'OP_STR': '=='}}]------------- ApiTestRunner.py test_case_execute 33
- 2024-11-04 20:25:46 INFO 测试用例名称:我的书评-发布正常的书评(优化-直接Josn断言),开始执行步骤0:提取评价的书籍ID - {'关键字': 'ex_mysqlData', '数据库': 'dsw_mysql', 'SQL': 'SELECT id FROM `book` ORDER BY RAND() LIMIT 1', '引用变量': 'id'} ApiTestRunner.py test_case_execute 42
- 2024-11-04 20:25:46 INFO -------------------测试用例名称:我的书评-发布正常的书评(优化-直接Josn断言)执行结束---------------------- ApiTestRunner.py test_case_execute 53
- 2024-11-04 20:25:47 INFO 用例ID:core/ApiTestRunner.py::TestRunner::test_case_execute[G2--P11] conftest.py pytest_runtest_makereport 68
- 2024-11-04 20:25:47 INFO 测试结果:failed conftest.py pytest_runtest_makereport 69
- 2024-11-04 20:25:47 INFO 故障表示:self = <apirun.core.ApiTestRunner.TestRunner object at 0x00000215ADCB22E0>
- caseinfo = {'_case_name': '我的书评-发布正常的书评(优化-直接Josn断言)', 'desc': '我的书评-发布正常的书评(优化-直接Josn断言)', 'featureName': '我的书评', 'process': 'G2--P', ...}
- def test_case_execute(self, caseinfo):
- casename = caseinfo["_case_name"]
- # TODO 2-1 : 调用动态生成标题的方法
- dynamicTitle(caseinfo)
-
- # TODO 2-2: 基于我们步骤一步步进行执行
- try:
- # 实例化关键字对象
- keywords = KeyWords()
-
- # 获取当前用例变量,方便后续的渲染
- local_context = caseinfo.get("context",{})
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
-
- steps = caseinfo.get("steps", None)
- logger.info(f"-----------------开始执行测试用例:{steps}-------------")
- for index,step in enumerate(steps):
- # 提示信息
- step_name = list(step.keys())[0]
- step_value = list(step.values())[0]
- # TODO : 每一个步骤进行变量的渲染
- context = copy.deepcopy(g_context().show_dict())
- context.update(local_context)
- step_value = eval(refresh(step_value, context))
- logger.info(f"测试用例名称:{casename},开始执行步骤{index}:{step_name} - {step_value}")
- # 基于每个步骤的关键字,找到对应的方法,然后把参数给它
- # 通过【反射】的方式去找到对应的方法
- with allure.step(step_name):
- key = step_value["关键字"] # 具体的方法名, 在 keywords 里面找到这个方法
- try:
- key_func = keywords.__getattribute__(key) # 从keywords获取到对应方法
- except AttributeError as e:
- logger.error(f"测试用例名称:{casename},没有这个关键字方法", e)
- > key_func(**step_value) # 调用方法
- core\ApiTestRunner.py:51:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- extend\keywords.py:183: in ex_mysqlData
- logger.info("数据库查询结果:", rs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1446: in info
- self._log(INFO, msg, args, **kwargs)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1589: in _log
- self.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1599: in handle
- self.callHandlers(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1661: in callHandlers
- hdlr.handle(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:952: in handle
- self.emit(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:380: in emit
- super().emit(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1091: in emit
- self.handleError(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:1083: in emit
- msg = self.format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:927: in format
- return fmt.format(record)
- ..\myenv\lib\site-packages\_pytest\logging.py:140: in format
- return super().format(record)
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:663: in format
- record.message = record.getMessage()
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <LogRecord: testlog, 20, D:\001_zzh\eng\api-engine\apirun\extend\keywords.py, 183, "数据库查询结果:">
- def getMessage(self):
- """
- Return the message for this LogRecord.
-
- Return the message for this LogRecord after merging any user-supplied
- arguments with the message.
- """
- msg = str(self.msg)
- if self.args:
- > msg = msg % self.args
- E TypeError: not all arguments converted during string formatting
- C:\Users\zhuzhenghui\AppData\Local\Programs\Python\Python39\lib\logging\__init__.py:367: TypeError conftest.py pytest_runtest_makereport 70
- 2024-11-04 20:25:47 INFO 异常:<ExceptionInfo TypeError('not all arguments converted during string formatting') tblen=43> conftest.py pytest_runtest_makereport 71
- 2024-11-04 20:25:47 INFO 用例耗时:0.22291740000000004 conftest.py pytest_runtest_makereport 72
- 2024-11-04 20:25:47 INFO ************************************** conftest.py pytest_runtest_makereport 73
|