Auty自動化測試框架第二篇——讀取與執行腳本列表


[本文出自天外歸雲的博客園]

在Auty中的文件結構,lib目錄下的read_selection.py和execute_selection.py文件:

其中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()

一個自動化測試框架至此已經有了骨架,接下來要完善日志收集、生成測試結果文件等功能。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM