編寫一個automation case的流程 php
http://192.168.20.105/projects/automation-test/wiki/Automation_DB_Management python
1.在testlink 裏添加一個manual test case, git
2. 將這個case 添加到test plan shell
3. 將test case 添加到Automation DB 裏面,而後經過 頁面 http://192.168.20.108/am/automation_case_list.php 查看,具體方法以下:
a.使用sync_db.sh, 去同步automation_test 數據庫:[at_Alan:root:~/automation/main/db/auto_db:develop]# ./sync_db.sh 數據庫
1 #!/bin/bash - 2 #=============================================================================== 3 # 4 # FILE: sync_db.sh 5 # 6 # USAGE: ./sync_db.sh 7 # 8 # DESCRIPTION: 9 # 10 # OPTIONS: --- 11 # REQUIREMENTS: --- 12 # BUGS: --- 13 # NOTES: --- 14 # AUTHOR: YOUR NAME (), 15 # ORGANIZATION: 16 # CREATED: 04/10/2013 04:08:22 PM CST 17 # REVISION: --- 18 #=============================================================================== 19 20 set -o nounset # Treat unset variables as an error 21 python ../db_obj.py 22 23 24 # 25 echo "=====================" 26 echo "check csv file contains non-ascii or not" 27 ls ./*.csv | xargs -i ./seek_no_ascii.sh {} ~
#!/usr/bin/env python 2 #coding=utf-8 3 from optparse import OptionParser 4 import sys, time, os,re 5 from pprint import pprint,pformat 6 from traceback import format_exc 7 from copy import deepcopy 8 import csv 9 from db_helper import db_helper 10 from log import getTestLogger 11 import MySQLdb 12 13 14 15 def group_iter(iterator, n=1, strict=False): 16 """ Transforms a sequence of values into a sequence of n-tuples. 17 E.g. [1, 2, 3, 4, …] =< [(1, 2), (3, 4), …] (when n == 2) 18 If strict, then it will raise ValueError if there is a group of fewer 19 than n items at the end of the sequence. """ 20 accumulator = [] 21 for item in iterator: 22 accumulator.append(item) 23 if len(accumulator) == n: # tested as fast as separate counter 24 yield tuple(accumulator) 25 accumulator = [] # tested faster than accumulator[:] = [] 26 # and tested as fast as re-using one list object 27 if strict and len(accumulator) != 0: 28 raise ValueError("Leftover values") 29 30 31 class at_excel(csv.Dialect): 32 """Describe the usual properties of Excel-generated CSV files.""" 33 delimiter = ',' 34 quotechar = '"' 35 doublequote = True 36 skipinitialspace = False 37 lineterminator = '\n' 38 quoting = csv.QUOTE_ALL 39 csv.register_dialect("at_excel", at_excel) 40 41 42 43 44 class DBI():
1 #!/bin/bash - 2 #=============================================================================== 3 # 4 # FILE: seek_no_ascii.sh 5 # 6 # USAGE: ./seek_no_ascii.sh 7 # 8 # DESCRIPTION: 9 # 10 # OPTIONS: --- 11 # REQUIREMENTS: --- 12 # BUGS: --- 13 # NOTES: --- 14 # AUTHOR: YOUR NAME (), 15 # ORGANIZATION: 16 # CREATED: 04/17/14 13:19:21 CST 17 # REVISION: --- 18 #=============================================================================== 19 20 set -o nounset # Treat unset variables as an error
b. 同步完成之後使用meld 工具對兩個文件夾auto_db(從數據庫中同步的, tables_scv(存放在git server上的文件)進行對比,保持兩個文件夾一致:[at_Alan:root:~/automation/main/db:develop]# meld auto_db/ tables_csv/ &
c. 在 /tables_csv 上作改動。注意,必定要在最後添加,順序添加index(不建議在中間添加,不然index 容易混亂)
d. 更改之後進行檢查,
./double_check_csv.py tables_csv/t_am_suite.csv -k tables_csv/t_am_keywordlib.csv vim
e: 進行文件轉換
/root/automation/main/db/tables_csv/./csv_tool.sh excel2db t_am_suite.csv xt_am_suite.csv
f:導入到db裏,首行跳過1,將表格數據進行替換…… bash
添加case 添加到 pf common目錄下面。 app
readlink -f $U_PATH_WIFITC/$current_case | xargs basename less
[at_Alan:root:~/automation/bin/2.0/common:develop]# vim wifi_configure.sh
[at_Alan:root:~/automation/testsuites/2.0/BAR1KH/cfg:develop]# vim CONFIG_LOAD 工具
[at_Alan:root:~/automation/platform/2.0/BAR1KH/config/33.120L.01a/wireless/CON:develop]#cp -s raw/B-GEN-WI.CON-002-C001 B-GEN-WI.CON-102-C001
添加軟連接:
ln -s 原文件 目標文件
調用andy的用selenuim file 替換postfile的方法,須要在case的的step裏添加getenv 去設置變量 G_PLAYBACK_METHOD=1,目的是爲了不percondition裏的大量的postfile 的替換,jenkins 的job裏面的變量 G_PLAYBACK_METHOD依然設置爲0
grep -r getenv *
<step> <name>0</name> <desc>Create env var U_TR069_DEF_INTERNAL_PORT_MID</desc> <getenv> echo "G_PLAYBACK_METHOD=1" </getenv> <passed></passed> <failed>998</failed> </step>
注意:這個變量改了之後,後面全部的case 都會按照 METHHOD = 1 的模式跑,因此正常的使用方法是隻能使用一種方法,全部的postfile 必須一致,要不就是method 0, 要不就method 1,要不就method 2.