[本文出自天外归云的博客园]

在Auty中的文件结构,lib目录下的read_selection.py和execute_selection.py文件:

Auty自动化测试框架第二篇——读取与执行脚本列表

其中read_selection.py文件的功能是把selection.txt文件中的可执行脚本列表读取并返回:

# -*- coding: utf-8 -*-
import sys
import os

def read_selection():
    path = os.path.abspath(os.path.dirname(__file__))
    parentPath = os.path.dirname(path)
    selectionFilePath = os.path.join(parentPath,'scripts','selection.txt')
    selection = []
    for line in open(selectionFilePath):
        selection.append(line.replace('\n',''))
    return selection

而execute_selection.py文件的功能是把read_selction.py文件返回的列表中包含的脚本在命令行中执行:

# -*- coding: utf-8 -*-
from .read_selection import read_selection
import os

def execute_selection():
    selection = read_selection()
    for scriptPath in selection:
        os.system('python '+scriptPath)

至此就可以在根目录的start.py脚本中执行execute_selection方法来执行所有的脚本文件了:

# -*- coding: utf-8 -*-
from lib.execute_selection import execute_selection

if __name__ == '__main__':
    execute_selection()

一个自动化测试框架至此已经有了骨架,接下来要完善日志收集、生成测试结果文件等功能。

 

相关文章:

  • 2021-08-09
  • 2021-05-27
  • 2021-08-19
  • 2021-11-20
  • 2021-09-14
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-14
  • 2022-12-23
相关资源
相似解决方案