# SimpleAuto **Repository Path**: sharkblue-ls/SimpleAuto ## Basic Information - **Project Name**: SimpleAuto - **Description**: 简单实用的接口自动化测试平台simpleauto - **Primary Language**: Python - **License**: AGPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 1 - **Created**: 2024-07-19 - **Last Updated**: 2025-02-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: Python, 接口自动化, 接口自动化测试平台 ## README # 启动流程 ## 1.安装环境 1.安装requirements.txt中库 2.安装redis 3.安装数据库mysql ## 2.配置修改 ```python DATABASES = { "default": { "ENGINE": "django.db.backends.mysql", "NAME": "simpleauto", "USER": "root", "PASSWORD": "sharkblue", "HOST": "127.0.0.1", "PORT": "3306", } } # Celery配置 CELERY_BROKER_URL = 'redis://127.0.0.1:6379/0' CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379/0' ``` 修改上述数据库与redis地址 ## 3.启动命令 1.python manage.py makemigrations 2.python manage.py migrate(迁移数据库) 3.python manage.py createsuperuser(创建超级用户) 4.python manage.py runserver 8000(启动服务) 5.127.0.0.1:8000/login/(登录地址) 6.127.0.0.1:8000/admin/(后端地址) 7.启动redis之后,才可启动定时任务 8.celery -A SimpleAuto worker --loglevel=info -P eventlet(定时任务) 9.Celery -A SimpleAuto worker --loglevel=info -P eventlet --logfile=/SimpleAuto/logs/worker.log(将定时任务日志写入worker.log) 10.celery -A SimpleAuto beat --loglevel=info(定时任务) 11.celery -A SimpleAuto flower(定时任务监控,地址http://localhost:5555) # 模块介绍 ## 首页 ![base.png](static%2Fimg%2Fbase.png) 1.近30天用例执行情况只统计测试集合执行的用例 ## 项目 ![project.png](static%2Fimg%2Fproject.png) ![project_statistics.png](static%2Fimg%2Fproject_statistics.png) ## 模块 ![module.png](static%2Fimg%2Fmodule.png) ![module_statistics.png](static%2Fimg%2Fmodule_statistics.png) ## 测试用例 ![test_case.png](static%2Fimg%2Ftest_case.png) 1.是否跳过勾选,则执行测试用例时不运行 2.点击执行测试用例,根据运行环境自动组合接口地址运行,结果保存在用例执行结果中 ![test_case_detail_1.png](static%2Fimg%2Ftest_case_detail_1.png) 1.请求头中支持 $参数名 引用参数,可引用公共参数中对应的参数或提取的参数,如有多个,默认取第一个 2.断言内容支持json格式断言、re断言,||为或多条件匹配,有一个成功则判定为成功 3.接口地址会自动获取运行环境配置的地址,并与接口地址组成完整地址 ![test_case_detail_2.png](static%2Fimg%2Ftest_case_detail_2.png) 1.&&为与断言,需全为真才判定成功,json或re提取后的值如果存在于响应中,则判定成功 2.如接口地址为http开头,则不与环境地址组合 ![test_case_detail_3.png](static%2Fimg%2Ftest_case_detail_3.png) 1.请求数据同样支持 $参数名 引用参数 2.提取变量支持json、re提取,供后续请求引用 ![test_case_detail_4.png](static%2Fimg%2Ftest_case_detail_4.png) ![test_case_detail_8.png](static%2Fimg%2Ftest_case_detail_8.png) ![test_case_detail_9.png](static%2Fimg%2Ftest_case_detail_9.png) 1.${函数}可引用自定义函数中的函数,接收返回值,传参全为字符,如函数需要特定格式,需在函数中处理 ![test_case_detail_5.png](static%2Fimg%2Ftest_case_detail_5.png) 1.如引入的参数为 $参数名[all],则会获取参数的每一个值都执行一条用例 2.如为 $参数名[2],则取参数中的第3个值(列表下标) 3.如请求头与请求数据都为 $参数名[all],则会执行n*m用例 ![test_case_detail_6.png](static%2Fimg%2Ftest_case_detail_6.png) ![test_case_detail_7.png](static%2Fimg%2Ftest_case_detail_7.png) 1.如果请求格式为"Content-Type":"application/x-www-form-urlencoded", 请求数据可以按URL编码格式填写,也可以按json格式填写 ## 测试集合 ![case_suite.png](static%2Fimg%2Fcase_suite.png) 1.是否跳过勾选则在运行测试集合时不运行,测试集合执行时,不会在判断里面关联的用例是否跳过,全执行 ![add_case_in_suite.png](static%2Fimg%2Fadd_case_in_suite.png) ![show_and_delete_case_in_suite.png](static%2Fimg%2Fshow_and_delete_case_in_suite.png) 1.编辑可编辑执行顺序,测试集合运行时以该顺序运行(建议尽量都填写,会影响参数的引用) ![case_suite_statistics.png](static%2Fimg%2Fcase_suite_statistics.png) ## 用例执行结果 ![test_case_execute_record.png](static%2Fimg%2Ftest_case_execute_record.png) ![show_result_diff.png](static%2Fimg%2Fshow_result_diff.png) ![show_exception.png](static%2Fimg%2Fshow_exception.png) ## 测试集合执行结果 ![case_suite_execute_record.png](static%2Fimg%2Fcase_suite_execute_record.png) ![suite_case_statistics.png](static%2Fimg%2Fsuite_case_statistics.png) ![suite_case_execute_record.png](static%2Fimg%2Fsuite_case_execute_record.png) ## 环境配置 ![env_info.png](static%2Fimg%2Fenv_info.png) ## 公共参数 ![arguments.png](static%2Fimg%2Farguments.png) 1.如需填写多个参数,以逗号隔开 ## 自定义函数 ![show_custom_code.png](static%2Fimg%2Fshow_custom_code.png) ## 定时任务 ![scheduled_task.png](static%2Fimg%2Fscheduled_task.png) 1.定时任务支持两种格式,一种为执行一次,即固定时间执行;一种为定期执行,即crontab格式 2.定时任务执行时,也不判断集合是否跳过,全执行 ![add_suite_in_scheduled.png](static%2Fimg%2Fadd_suite_in_scheduled.png) ![show_and_delete_suite_in_scheduled.png](static%2Fimg%2Fshow_and_delete_suite_in_scheduled.png) ![scheduled_task_statistics.png](static%2Fimg%2Fscheduled_task_statistics.png) 1.显示定时任务执行过的所有集合数据,即使已删除该集合的关联