- Python版本 2.7.10-2.7.14
- django版本 1.11以上
- redis最新版本(可以不安装)
- djangorestframework 3.8.2以上
- mysql 5.7
- 安装依赖,项目根目录执行命令 pip install -r requirements.txt
- mysql建表,并设置为utf-8
create database auto_ui DEFAULT CHARACTER set utf8;
- 根目录创建执行合表,全部ok表示成功
python manage.py migrate
- 建连接db的配置文件
# config_aotu_ui.yaml --- db: ip: localhost port: 3306 table: aotu_ui uname: root passwd: 123456
- 设置文件访问路径auto_ui--Config.py 文件修改路径
if platform.system() == "Windows": path = os.path.join('d:\config_auto_ui.yaml') else: path = os.path.join('/usr/local/aotuConfig/config_auto_ui.yaml') f = open(path) s = yaml.load(f) f.close() return s
- 启动auto_ui, 允许外网访问
python manage.py runserver 0.0.0.0:8000
- 先来看看数据库的字段, 只要在每条用例跑完后将对应字段结果入库即可,
需注意是ReportDetail和ReportInfo为uuid关联,每次运行跑脚本需要生成一个全局的uuid
global uuid uuid = uuid.uuid1() # 生成全局唯一id
# ReportDetail 对应字段 precondition = models.CharField("前置条件", max_length=255, default=None) case_name = models.CharField("case名称", max_length=128, default=None) check_step = models.CharField("检查步骤", max_length=128, default=None) title = models.CharField("用例标题", max_length=64, default=None) step = models.TextField("测试步骤", max_length=2048, default=None) phone_name = models.CharField("机型", max_length=64, default=None) result = models.ImageField("测试结果", default=0) screenshots_path = models.ImageField("测试图片,传入图片路径即可", upload_to='upload', default=None) msg = models.TextField("失败原因", max_length=1024, default=None) case_id = models.CharField("case_id", max_length=64, default=None) report_uuid = models.CharField("每次运行唯一md5标识", max_length=256, default=None) report_create_time = models.DateTimeField("创建时间", auto_now=False, auto_now_add=True) report_update_time = models.DateTimeField("更新时间", auto_now=True, auto_now_add=False) platform_name = models.TextField("系统类型", max_length=16, default="android") case_step_time = models.TextField("测试步长,json格式", max_length=2048, default=None)
# ReportInfo 对应字段 case_sum = models.IntegerField("case总和", default=0) case_pass_sum = models.IntegerField("通过case总和", default=0) case_fail_sum = models.IntegerField("失败case总和", default=0) case_date = models.DateTimeField("测试日期", auto_now=False, auto_now_add=True) case_run_time = models.CharField("测试总耗时", max_length=64, default="0") platform_name = models.TextField("系统类型", max_length=16, default="android") platform_env = models.TextField("运行环境", max_length=16, default="stage") report_uuid = models.CharField("每次运行唯一md5标识", max_length=256, default=None) report_info_create_time = models.DateTimeField("创建时间", auto_now=False, auto_now_add=True) report_info_update_time = models.DateTimeField("更新时间", auto_now=True, auto_now_add=False)