- 1. 鏈接測試
1.1 測試點:
- 是否添加鏈接
- 鏈接頁面是否存在
- 鏈接頁面與需求是否一致:頁面的正確性、打開方式 等
一般,該鏈接測試在集成測試階段(頁面均開發完成)的時候進行
1.2 測試工具:
-
Xenu Link Sleuth 免費 綠色免安裝軟件
-
HTML Link Validator 共享(30天試用)
1.3 延伸代碼:
測試工具在實際應用時,其實是挺受限的。有時候,需要自己寫點小代碼去驗證,主要用於系統回歸。
比如:

1 // 封裝判斷web鏈接返回狀態是否為2開頭的 2 public static void ReadUrl(String surl){ 3 try { 4 URL url = new URL(surl); 5 URLConnection rulConnection = url.openConnection(); 6 HttpURLConnection httpUrlConnection = (HttpURLConnection) rulConnection; 7 httpUrlConnection.setConnectTimeout(300000); 8 httpUrlConnection.setReadTimeout(300000); 9 httpUrlConnection.connect(); 10 String code = new Integer(httpUrlConnection.getResponseCode()).toString(); 11 String message = httpUrlConnection.getResponseMessage(); 12 // System.out.println("getResponseCode code ="+ code); 13 // System.out.println("getResponseMessage message ="+ message); 14 if(!code.startsWith("2")){ 15 throw new Exception(surl+"ResponseCode is not begin with 2,code="+code); 16 } 17 // 打印鏈接返回狀態碼 18 // System.out.println(getDateTime()+"連接"+surl+"正常"); 19 }catch(Exception ex){ 20 // System.out.println(surl+ex.getMessage()); 21 } 22 } 23 24 // 封裝模擬發起post請求一 25 public static String sendPost(String strUrl, String content, String charset) { 26 URL httpurl = null; 27 HttpURLConnection httpConn = null; 28 String returnStr = ""; 29 PrintWriter outs = null; 30 try { 31 httpurl = new URL(strUrl); 32 httpConn = (HttpURLConnection) httpurl.openConnection(); 33 httpConn.setRequestMethod( "POST"); // 默認是post 34 // 設置是否向httpUrlConnection輸出,因為這個是post請求,參數要放在 http正文內,因此需要設為true, 默認情況下是false; 35 httpConn.setDoOutput( true); 36 // 設置是否從httpUrlConnection讀入,默認情況下是true; 37 httpConn.setDoInput( true); 38 httpConn.setRequestProperty( "Content-Type", "text/xml"); 39 outs = new PrintWriter(httpConn.getOutputStream()); 40 outs.print(content); 41 outs.flush(); 42 outs.close(); 43 // 字節流 讀取全部內容 包括換行符 44 returnStr = inputStreamToString(httpConn.getInputStream(), charset); 45 } catch (Exception e) { 46 logger.error( "執行HTTP Post請求" + strUrl + "時,發生異常!" , e); 47 if(outs != null){ 48 outs.close(); 49 outs = null; 50 } 51 return returnStr; 52 } finally { 53 if (httpConn != null) 54 httpConn.disconnect(); 55 if(outs != null){ 56 outs.close(); 57 outs = null; 58 } 59 } 60 return returnStr; 61 } 62 63 // 封裝讀取請求響應的內容 64 public static String inputStreamToString(InputStream in,String encoding) throws Exception{ 65 ByteArrayOutputStream outStream = new ByteArrayOutputStream(); 66 byte[] data = new byte[1024]; 67 int count = -1; 68 while((count = in.read(data,0, 1024)) != -1) 69 outStream.write(data, 0, count); 70 in.close(); 71 data = null; 72 return new String(outStream.toByteArray(),encoding); 73 }

1 void((function() { 2 var cars=new Array();//定義了數組,最終返回的是列表 3 4 cars=document.getElementsByTagName("a");//獲取對應對象 5 /*cars=$("a")*/ 6 for(var i =0;i<cars.length;i++){ 7 var href_name; 8 item_name = cars[i].href; //獲取對應url地址 9 if(item_name.indexOf("***")!=-1){ 10 console.info(item_name); 11 } 12 } 13 14 })()) 15 var xmlhttp; 16 function loadXMLDoc(url) 17 { 18 xmlhttp=null; 19 if (window.XMLHttpRequest) 20 {// code for Firefox, Mozilla, IE7, etc. 21 xmlhttp=new XMLHttpRequest(); 22 } 23 else if (window.ActiveXObject) 24 {// code for IE6, IE5 25 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 26 } 27 if (xmlhttp!=null) 28 { 29 xmlhttp.onreadystatechange=state_Change; 30 xmlhttp.open("GET",url,true); 31 xmlhttp.send(null); 32 } 33 else 34 { 35 alert("Your browser does not support XMLHTTP."); 36 } 37 } 38 39 function state_Change() 40 { 41 if (xmlhttp.readyState==4) 42 {// 4 = "loaded" 43 if (xmlhttp.status==200) 44 {// 200 = "OK" 45 document.getElementById('p1').innerHTML=xmlhttp.getAllResponseHeaders(); 46 } 47 else 48 { 49 alert("Problem retrieving data:" + xmlhttp.statusText); 50 } 51 } 52 }
- 2. 表單測試
2.1 測試點:
- 默認值
- 必輸項
- 輸入驗證:輸入框的特殊文本控制(比如電話、郵箱、url地址等)、長字符、特殊字符、正負數、小數位數等。
- 上傳測試:大小、格式類型等
- 表單操作:增刪改查,完整性、正確性。
一般,配合下面的數據校驗等方面一起測試的,故這里的測試點可能不全。
2.2 測試工具:
WinRunner(QTP)等
先手動檢查,后可以用該工具回歸了。
2.3 延伸代碼:
可以寫個簡單的js實現

1 void((function(){ 2 var select = document.getElementsByTagName('select'); 3 for(var jj=0;jj<select.length;jj++){ 4 selectedNode = select[jj].options; 5 /*取出select的所有選項值*/ 6 for (var i=0;i<selectedNode.length;i++){ 7 selectoption=selectedNode[i].innerHTML; 8 // console.info(selectoption); 9 10 } 11 /*隨機賦值*/ 12 /*隨機賦值*/ 13 $(select[jj]).get(0).selectedIndex=1; 14 var checkText= $(select[jj]).find("option:selected").text(); 15 console.info(checkText); 16 $(select[jj]).click; 17 18 } 19 })()) 20 21 //一般的文本框任意賦值 22 void((function() { 23 var i = document.getElementsByTagName('input'); 24 for (var jj = 1; jj <= i.length-4; jj++) { 25 i[jj].value = "cs"; 26 } 27 })())
也可以使用代碼等,比如selenium等。
- 3. 數據校驗
3.1 測試點:
- 配合2的測試,驗證表單數據的正確及完整性:單頁面、單系統或多系統。
- 數據的增刪改查:比如代碼任務的計算等
該方面的測試,與每個系統特異性有關,故不全。
3.2 測試工具:同上
3.3 代碼延伸
- 4. cookies測試
4.1 測試點:
- 是否使用cookies:根據需求設計,確定是否使用了cookies。比如說需求需要將選擇的類目保存到cookie,關閉瀏覽器然后再試;或者某些不能使用cookie等。
- cookies其他使用需求驗證:比如使用 cookie 來統計次數,需要驗證次數累計正確。
該方面的測試,與每個系統特異性有關,故不全。
4.2 測試工具:
IECookiesView v1.50
Cookies Manager v1.1
-
5. 數據庫測試
5.1 測試點
我目前測試接觸到的數據是oracle、mysql。
主要測試數據庫的經歷是oracle,哎呀,但是換了工作后,好幾年不碰了,下次整理了。
- sql語句的性能及優化
5.2 測試工具
使用及測試的工具可能是1個,可能是多個聯合
TOAD for Oracle(Mysql)
- 6. 應用程序特定的功能需求
深刻理解需求說明文檔
比如
- 與第三平台之間的交互等
- session測試:同個瀏覽器打開兩個頁面,一個頁面權限失效后,另一個頁面是否可操作成功等。
- 7. 控件等技術應用測試
7.1 測試點
- 是否滿足使用需求
- 界面顯示是否正常
- 控件的正確性:多種操作后是否正常等