编写一个automation case的流程
http://192.168.20.105/projects/automation-test/wiki/Automation_DB_Management
1.在testlink 里添加一个manual test case,
2. 将这个case 添加到test plan
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 {}
~
db_obj.py
#!/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
e: 进行文件转换
/root/automation/main/db/tables_csv/./csv_tool.sh excel2db t_am_suite.csv xt_am_suite.csv
f:导入到db里,首行跳过1,将表格数据进行替换……
添加case 添加到 pf common目录下面。
readlink -f $U_PATH_WIFITC/$current_case | xargs basename
[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.