理論部分html
1.測試分爲哪幾個階段python
2.測試的流程是什麼android
3.如何作好測試計劃git
4.常見的測試用例設計方法有哪些web
5.一條bug記錄包含哪些內容算法
5.如何分層自動化測試shell
6.如何保證腳本的有效性數據庫
7.如何下降自動化維護成本編程
8.常見的測試覆蓋類型json
9.B/S和C/S架構什麼區別
,客戶端,好比微信,QQ
,瀏覽器頁面,好比百度頁面
10.安全性都包含哪些內容
11.測試報告都包含哪些內容
12.Alpha和Beta測試的區別是什麼
13.bug的類型都有哪些
Python部分
1.面向對象的概念
代碼示例:
1 # Animal是類,相同事物的統稱 2 class Animal(object): 3 def run(self): 4 print('Animal is running...') 5 6 7 # Dog類,繼承於Animal類 8 class Dog(Animal): 9 pass 10 11 puppy = Dog() 12 puppy.run() 13 14 # 多態,子類方法覆蓋父類方法 15 class Cat(Animal): 16 def __init__(self, name): 17 # __name是屬性 18 self.__name = name 19 20 def getName(self): 21 print(self.__name) 22 23 def run(self): 24 print('Cat is running...') 25 26 27 # limi是一個貓類的實例 28 limi = Cat("limi") 29 # run是實例的一個方法 30 limi.run() 31 # getName方法 32 limi.getName()
2.什麼是進程,線程,協程
代碼示例:
1 # encoding: utf-8 2 #進程 3 # from multiprocessing import Process 4 # 5 # def foo(i): 6 # print("This is Process ", i) 7 # 8 # for i in range(5): 9 # p = Process(target=foo, args=(i,)) 10 # p.start() 11 12 #線程 13 # import threading 14 # 15 # def show(i): 16 # print('This is Thread', i) 17 # 18 # for i in range(5): 19 # t = threading.Thread(target=show, args=(i,)) 20 # t.start() 21 22 #協程 23 import gevent 24 25 def foo(): 26 print("start_foo") 27 gevent.sleep(2) 28 print("end_foo") 29 30 def bar(): 31 print("start_bar") 32 gevent.sleep(0) 33 print("end_bar") 34 35 # foo() 36 # bar() 37 gevent.joinall([ 38 gevent.spawn(foo), 39 gevent.spawn(bar), 40 ])
3.如何使用python實現socket編程
1 #encoding: utf-8 2 #服務端 3 4 # 導入 socket 模塊 5 import socket 6 7 # 建立 socket 對象 8 s = socket.socket() 9 # 綁定端口 10 s.bind(("127.0.0.1", 6666)) 11 12 # 等待客戶端鏈接 13 s.listen(5) 14 15 while True: 16 # 創建客戶端鏈接 17 c, addr = s.accept() 18 print '鏈接地址:', addr 19 c.send('Welcome') 20 # 關閉鏈接 21 c.close()
1 #encoding: utf-8 2 客戶端 3 # 導入 socket 模塊 4 import socket 5 6 # 建立 socket 對象 7 s = socket.socket() 8 9 #鏈接服務端 10 s.connect(("127.0.0.1", 6666)) 11 print s.recv(1024) 12 s.close()
4.什麼是lambda函數
1 #encoding: utf-8 2 3 #計算平方 4 def square(x): 5 return x**2 6 7 print square(10) 8 9 10 #lambda表達式 11 r = lambda x:x**2 12 print r(10)
5.tuple和list有什麼區別
6.range()函數的用法
1 #range生成從0到100的列表 2 alist = range(0, 101) 3 print(alist) 4 5 #設置步長爲2 6 blist = range(2, 101, 2) 7 print(blist)
7.字符串的拆分方法有哪些
8.單引號,雙引號,三引號的區別
9.*args,**kwargs有什麼做用
1 #encoding: utf-8 2 3 #arg 4 def test_args(first, *args): 5 print first 6 for v in args: 7 print "args %s" % v 8 9 #args = (2, 3, 4, 5) 10 test_args(1, 2, 3, 4, 5, 6) 11 12 #kwargs 13 def test_kwargs(first, *args, **kwargs): 14 print first 15 for v in args: 16 print "args %s" % v 17 for k, v in kwargs.items(): 18 print "kwargs", (k, v) 19 #args = (2, 3, 4, 5) 20 #kwargs: k1=5, k2=6, k0=4 21 test_kwargs(1, 2, 3, 4, 5, k0=4, k1=5, k2=6)
10.python中pass語句的做用
1 #encoding: utf-8 2 3 def test(): 4 pass 5 6 test()
11.re模塊中match和search方法的不一樣
1 #encoding: utf-8 2 import re 3 4 s1 = "helloworld, helloworld" 5 w1 = 'hello' 6 w2 = 'world' 7 8 #search掃描整個字符串 9 print(re.search(w2, s1)) 10 print(re.search(w2, s1).group()) 11 12 #match只在字符串開始的位置匹配 13 print(re.match(w2, s1)) 14 print(re.match(w2, s1).group())
12.WSGI和FastCGI的的關係
13.python是如何操做文件的
1 #encoding: utf-8 2 3 #寫文件 4 f = open('test.txt', 'wt') 5 f.write("hello world") 6 f.close() 7 8 #使用with,追加內容,不用關心文件關閉問題 9 with open("test.txt", 'at') as f: 10 f.write("\nhello mook") 11 12 #讀取文件 13 with open("test.txt", 'rt') as f: 14 print(f.read())
14.python的內存管理機制
1 #encoding: utf-8 2 from sys import getrefcount 3 4 #引用計數 5 a1 = 10000000 6 a2 = 10000000 7 #del a1 8 del a2 9 10 print(id(a1)) 11 #print(id(a2)) 12 13 #檢驗a1和a2是同一個東西 14 #print(a1 is a2) 15 16 # #獲取a2的引用計數 17 print(getrefcount(a1))
15.dict的items與iteritems的區別
1 #encoding: utf-8 2 3 testl = {'key1': 2, 'key2': 3, 'key3': 4} 4 5 kv1 = testl.items() 6 # print(next(kv1)) 7 8 kv2 = testl.iteritems() 9 print(next(kv2)) 10 print(next(kv2)) 11 print(next(kv2))
16.python經常使用算法
sorted()方法排序後生成新的列表,不會改變原來的列表
list.sort()方法排序後會改變原來的列表
1 #encoding: utf-8 2 3 alist = [0, 10, 88, 19, 9, 1] 4 #print(sorted(alist)) 5 6 #print(sorted(alist, reverse=True)) 7 8 alist.sort(reverse=True) 9 print(alist)
冒泡排序:
1 #encoding: utf-8 2 3 # 冒泡排序 4 def bubble_sort(lists): 5 #獲取數組長度 6 count = len(lists)-1 7 itemrange = range(count, 0, -1) 8 #N個元素遍歷N次 9 for index in itemrange: 10 #第i個和第i+1個依次對比 11 for sub_index in range(index): 12 #大的元素冒上去 13 if lists[sub_index] > lists[sub_index+1]: 14 lists[sub_index],lists[sub_index+1]=lists[sub_index+1],lists[sub_index] 15 return lists 16 17 alist = [0, 10, 88, 19, 9, 1] 18 print(bubble_sort(alist))
快速排序:
1 #encoding: utf-8 2 # 快速排序 3 def quick_sort(lists, left, right): 4 #遞歸過程當中,發現left和right一致時,中止遞歸,直接返回列表 5 if left >= right: 6 return lists 7 #定義遊標 8 low = left 9 high = right 10 11 #取參考標誌,最左邊的元素 12 key = lists[low] 13 while low < high: 14 #從最右側向左,依次和標誌元素對比,若是右側的元素大於標誌元素 15 while low < high and lists[high] >= key: 16 #右側減1 17 high -= 1 18 #不然low賦high值 19 lists[low] = lists[high] 20 21 #從最左側向右,依次和標誌元素對比,若是左側的元素小於標誌元素 22 while low < high and lists[low] <= key: 23 #左側加1 24 low += 1 25 #不然high賦low值 26 lists[high] = lists[low] 27 28 #最後給high位置賦值 29 lists[high] = key 30 31 #處理左側元素 32 quick_sort(lists, left, low - 1) 33 #處理右側元素 34 quick_sort(lists, low + 1, right) 35 return lists 36 37 alist = [0, 10, 88, 19, 9, 1, 7] 38 print(quick_sort(alist, 0, 6))
堆排序:
1 #encoding: utf-8 2 3 def heap_sort(lst): 4 def sift_down(start, end): 5 """最大堆調整""" 6 root = start 7 print "root %d start %d end %d"%(root, start, end) 8 while True: 9 child = 2 * root + 1 10 #print "child index: %d" % child 11 12 #終止條件,孩子的索引值超過數組最大長度 13 if child > end: 14 break 15 #print "lst child value:%d" % lst[child] 16 17 #肯定最大的孩子節點的索引值 18 if child + 1 <= end and lst[child] < lst[child + 1]: 19 child += 1 20 #print "child+1 index: %d" % child 21 22 #孩子節點最大值和根節點交換 23 if lst[root] < lst[child]: 24 lst[root], lst[child] = lst[child], lst[root] 25 #print "lstroot %d" % lst[root], "lstchild %d" % lst[child] 26 root = child 27 #print "root %d" % root 28 else: 29 break 30 31 print("-----------------建立最大堆------------------") 32 # 建立最大堆 33 print(xrange((len(lst) - 2) // 2, -1, -1)) 34 for start in xrange((len(lst) - 2) // 2, -1, -1): 35 print "---->Loop start %d" % start 36 sift_down(start, len(lst) - 1) 37 print(lst) 38 39 print("-----------------排序過程------------------") 40 # 堆排序 41 for end in xrange(len(lst) - 1, 0, -1): 42 #首尾交換 43 lst[0], lst[end] = lst[end], lst[0] 44 #剩餘從新堆排序 45 sift_down(0, end - 1) 46 print(lst) 47 return lst 48 49 50 alist = [70, 60, 12, 40, 30, 8, 10] 51 print(heap_sort(alist))
二分查找:
1 # encoding: utf-8 2 3 alist = [0, 1, 10, 88, 19, 9, 1] 4 5 6 def binary_search(arr, start, end, hkey): 7 if start > end: 8 return -1 9 mid = start + (end - start) / 2 10 if arr[mid] > hkey: 11 return binary_search(arr, start, mid - 1, hkey) 12 if arr[mid] < hkey: 13 return binary_search(arr, mid + 1, end, hkey) 14 return mid 15 16 17 alist = sorted(alist) 18 print(alist) 19 print binary_search(alist, 0, 6, 9)
素數(質數):
1 #encoding: utf-8 2 3 #0,1不是素數 4 #除了1和它自身外,不能被其餘天然數整除的數 5 def is_prime(n): 6 if n <= 1: 7 return False 8 9 for i in range(2, n-1): 10 if n % i == 0: 11 return False 12 return True 13 14 for i in range(0, 100): 15 if is_prime(i): 16 print i
Linux部分
基礎命令
網絡命令:
系統命令:
計算機網絡相關
1.OSI網絡七層模型指的哪些內容
2.http協議中get,post的區別
2.tcp和udp的區別
3.tcp鏈接3次握手的具體過程
tcp鏈接4次揮手的過程(主動方能夠是客戶端,也能夠是服務端)
4.socket創建鏈接的過程
操做系統相關
1.進程與線程的區別
2.進程都有哪些狀態
3.進程同步與互斥的區別
4.進程間通訊都包括哪些
5.進程的調度算法有哪些
6.死鎖產生的緣由
7.頁面置換算法都有哪些
8.makefile的做用是什麼
9.什麼是虛存,實存,共享內存
MySQL相關
1.建立數據庫:CREATE DATABASE 數據庫名;
2.刪除數據庫:DROP DATABASE 數據庫名;
3.建立數據表:CREATE TABLE 表名;
4.插入數據:INSERT INTO 表名 VALUES(內容);
5.查詢數據:SELECT 字段名 FROM 表名 WHERE 條件;
6.更新數據:UPDATE 表名 SET 字段名=新值 WHERE 條件;
7.刪除數據表:DROP TABLE 表名;
Fiddler工具相關
1.如何抓取手機包
具體使用過程,能夠參考本身以前的博客:http://www.cnblogs.com/ailiailan/p/hanxiaobei.html
2.實現慢網速,過濾
過濾:
慢網速:
自定義修改延時時間:
Android相關
1.Android的四大組件
2.Activity的生命週期
Activity的4個狀態:運行、暫停、中止、關閉;關閉有系統來完成。
4個狀態間的轉換過程圖:
3.什麼是ANR
ANR:應用無響應,是由系統來監控應用程序的,若是應用程序超時,系統會彈出ANR提示
4.Android常見的5種佈局
5.Android中動畫類型有哪幾種
ADB相關
1.重啓adb服務
2.app的安裝與卸載
3.電腦和手機之間傳輸數據
4.如何靜默安裝app
5.adb命令啓停一個app
-S:若是app已經啓動了,先執行中止app,再啓動
6.經過關鍵字查找已安裝的包
-f:全部包 -3:第三方包 -i:已經安裝的包
7.截屏、錄屏
8.抓log
9.獲取當前CPU,內存狀態
Monkey相關
1.Monkey進行壓力測試的命令
2.如何重現crash,anr
3.如何提取crash,anr信息
adb shell monkey -v -v -v -p packagename count >文件名.txt (3個-v會顯示最詳細的log信息)
4.如何設置monkey運行8個小時
--throttle 毫秒數 (定義兩個動做之間的時間間隔) 時間間隔 * count = 總執行時間
5.在crash/anr出現後,如何繼續執行
6.monkey執行指定的事件類型
自動化工具
1.Instrumentation的原理是什麼
2.Instrumentation用來測試什麼
3.何時用Instrumentation
4.UIAutomator是什麼
5.UIAutomator能夠測試什麼
6.如何識別App視圖內的元素
7.Selendroid原理
8.Robotium原理
9.Appium的理念是什麼
10.Appium相關概念
11.Appium的環境
12.Appium初始化須要配置哪些內容
13.Appium測試Native App的原理
14.Appium測試Hybrid App的原理
15.Appium測試Ios App的原理
16.Native App元素的定位工具
17.定位元素的Api有哪些
18.Native App腳本的編寫原則
19.Native App初始化注意事項
20.Hybrid App的定位方式
21.Hybrid App腳本的編寫原則
22.Hybrid App初始化注意事項
自動化框架
1.unittest框架都包含哪些內容
TestFixture包含
2.什麼是數據驅動
3.數據驅動DDT的原理
4.數據驅動DDT的意義
5.什麼是行爲驅動
6.行爲驅動Lettuce的原理是什麼
代碼示例:
自動化測試代碼:
1 #encoding:utf-8 2 from lettuce import * 3 from appium import webdriver 4 5 @before.each_scenario 6 def lauchApp(scenario): 7 desired_caps = {} 8 desired_caps['platformName'] = 'Android' 9 desired_caps['platformVersion'] = '5.1' 10 desired_caps['deviceName'] = '192.168.56.102:5555' 11 desired_caps['appPackage'] = 'com.android.calculator2' 12 desired_caps['appActivity'] = '.Calculator' 13 desired_caps["unicodeKeyboard"] = "True" 14 desired_caps["resetKeyboard"] = "True" 15 world.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps) 16 17 @after.each_scenario 18 def closeApp(scenario): 19 world.driver.quit() 20 21 @step("I have two number: (\d+) and (\d+)") 22 def have2number(step, number1, number2): 23 world.number1 = number1 24 world.number2 = number2 25 26 @step("Do add method") 27 def doAdd(step): 28 numa = world.driver.find_element_by_id("digit_"+world.number1) 29 numa.click() 30 31 add = world.driver.find_element_by_id("op_add") 32 add.click() 33 34 numb = world.driver.find_element_by_id("digit_"+world.number2) 35 numb.click() 36 37 equal = world.driver.find_element_by_id("eq") 38 equal.click() 39 40 world.result = world.driver.find_element_by_class_name("android.widget.EditText").text 41 42 @step("I get result: (\d+)") 43 def judgeResult(step, result): 44 assert result == world.result, "The result are not equal %s and %s" %result and world.result
測試用例:
1 Feature: Calculation 2 Input two number, then compare result 3 4 Scenario: Do a simple add method 5 Given I have two number: 1 and 5 6 When Do add method 7 Then I get result: 6 8 9 Scenario: Do a simple add method 10 Given I have two number: 2 and 5 11 When Do add method 12 Then I get result: 8
7.什麼是關鍵字驅動
8.關鍵字驅動測試框架Robot framework的原理
RIDE工具:
9.測試報告管理
代碼示例:
1 #encoding: utf-8 2 import unittest 3 import time 4 from HTMLTestRunner import HTMLTestRunner 5 6 class MyTestCase(unittest.TestCase): 7 #每條用例初始化 8 def setUp(self): 9 self.initdata = "hello imooc" 10 #測試用例,以test開頭 11 def test_something(self): 12 self.assertEqual("hello imooc", self.initdata) 13 #每條用例執行完後釋放資源 14 def tearDown(self): 15 pass 16 17 if __name__ == '__main__': 18 #聲明一個suite 19 suite = unittest.TestSuite() 20 #從類加載用例集 21 cases = unittest.TestLoader().loadTestsFromTestCase(MyTestCase) 22 #添加用例到suite 23 suite.addTests(cases) 24 25 #生成HTMLTestReport 26 #以時間戳來定義報告名稱 27 now = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time())) 28 HtmlFile = "report/" + now + "_Report.html" 29 fp = file(HtmlFile, "wb") 30 31 #聲明一個runner 32 myTestRunner = HTMLTestRunner(stream=fp, title=u"測試報告", description=u"用例測試狀況") 33 34 #執行Runner 35 myTestRunner.run(suite) 36 fp.close()
10.郵件通知
代碼示例:
#!/usr/bin/python # -*- coding: utf8 -*- import smtplib from email.mime.text import MIMEText mail_host = "smtp.163.com" # 設置服務器 mail_user = "Yannan@163.com" # 用戶名 mail_pass = "tester123" # 口令 mail_postfix = "163.com" # 發件箱的後綴 # to_list:收件人;sub:主題;content:郵件內容 def send_mail(to_list, sub, reportpath): file = open(reportpath, "rb") content = "" for line in file.readlines(): content = content + line.replace("class='hiddenRow'", "") # 這裏的hello能夠任意設置,收到信後,將按照設置顯示 me = "TestCenter" + "<" + mail_user + ">" # 建立一個實例,這裏設置爲html格式郵件 msg = MIMEText(content, _subtype='html', _charset='utf-8') # 設置主題 msg['Subject'] = sub msg['From'] = me msg['To'] = ";".join(to_list) try: s = smtplib.SMTP() # 鏈接smtp服務器 s.connect(mail_host) # 登錄服務器 s.login(mail_user, mail_pass) # 發送郵件 s.sendmail(me, to_list, msg.as_string()) s.close() return True except Exception, e: return False
接口測試相關
1.Fiddler抓取https包
2.如何實現一個Api測試框架
3.如何使用Python requests實現get請求
代碼示例:
1 #encoding: utf-8 2 3 import requests 4 import unittest 5 import ddt 6 7 @ddt.ddt 8 class testClass(unittest.TestCase): 9 10 @ddt.data("App專項測試", "自動化", "Python") 11 def testGet(self, queryword): 12 #header部分的配置 13 headers_data = { 14 'User-Agent':'Mozilla/5.0 (Linux; Android 5.1.1; Nexus 6 Build/LYZ28E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Mobile Safari/537.36', 15 'Host':'m.imooc.com', 16 'Referer': 'https://m.imooc.com/', 17 'Connection':'keep-alive', 18 'Accept-Encoding':'gzip, deflate, br' 19 } 20 21 #cookies部分的配置 22 cookies_data = dict(imooc_uuid='ffbd103a-b800-4170-a267-4ea3b301ff06', 23 imooc_isnew_ct='1511175583', 24 imooc_isnew='2', 25 page = 'https://m.imooc.com/') 26 27 #get請求的構造 28 res = requests.get( 29 "https://m.imooc.com/search/?words="+queryword, 30 headers=headers_data, 31 cookies=cookies_data) 32 33 #print res.status_code 34 #print res.text 35 36 self.assertTrue(u"共找到" in res.text) 37 38 if __name__ == "__main__": 39 unittest.main()
4.如何使用Python requests實現post請求
代碼示例:
1 #encoding: utf-8 2 import requests 3 import unittest 4 import ddt 5 6 @ddt.ddt 7 class testClass(unittest.TestCase): 8 9 @ddt.data( 10 ("15977778888", "999999"), 11 ("15977778889", "999998") 12 ) 13 @ddt.unpack 14 def testPost(self, username_data, password_data): 15 formdata = { 16 "username": username_data, 17 "password": password_data, 18 "verify": '', 19 "referer":'https://m.imooc.com'} 20 21 headers_data = { 22 'User-Agent': 'Mozilla/5.0 (Linux; Android 5.1.1; Nexus 6 Build/LYZ28E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Mobile Safari/537.36', 23 'Host': 'm.imooc.com' 24 } 25 26 #cookies部分的配置 27 cookies_data = dict(imooc_uuid='ffbd103a-b800-4170-a267-4ea3b301ff06', 28 imooc_isnew_ct='1511175583', 29 imooc_isnew='2', 30 page = 'https://m.imooc.com/') 31 32 res = requests.post("https://m.imooc.com/passport/user/login", 33 data = formdata, 34 headers = headers_data, 35 cookies = cookies_data 36 ) 37 38 print res.json() 39 40 self.assertTrue(90003 == res.json()['status'] or 10005 == res.json()['status']) 41 42 if __name__ == "__main__": 43 unittest.main()
5.什麼是持續集成
6.持續集成都包括哪些內容
7.持續集成有什麼意義
8.實現持續集成的工具備哪些
9.如何搭建Jenkins持續集成平臺
10.使用Jenkins須要作哪些配置
11.持續集成的應用
服務端測試
1.服務端壓力測試須要關注哪些指標
兼容性測試
1.App兼容性測試都考慮哪些因素
能夠藉助雲測平臺,提升兼容性測試的覆蓋度
2.WAP網頁兼容性測試都考慮哪些因素
3.PC網頁兼容性測試都考慮哪些因素
Bug 調試與定位
1.APP相關的bug調試工具備哪些
2.WAP網頁相關的bug調試工具備哪些
3.PC網頁相關的bug調試工具備哪些