查看日志命令
Linux查看命令有多種:tail,head,cat,tac,more 參考資料
一、 tail命令
-
參數(shù):
-f 循環(huán)讀取
-q 不顯示處理信息
-v 顯示詳細的處理信息
-c<數(shù)目> 顯示的字節(jié)數(shù)
-n<行數(shù)> 顯示行數(shù)
應用:
| 命令 | 含義 |
|---|---|
| tail -f test.log | 查看實時日志 |
| tail -100f test.log | 查看最后100行日志記錄 |
| tail -n 10 test.log | 查詢日志尾部最后十行的日志 |
| tail -n +10 test.log | 查詢十行之后歐的所有日志 |
| tail -fn 100 test.log | 循環(huán)實時查看最后100行記錄 |
-
head命令
1.功能
跟tail是相反的,tail是查看后多少行日志,head是查看前多少行日志。
2.應用
命令 含義 Head -n 10 test.log 查詢日志文件中的前10行日志 Head -n -10 test.log 查詢日志文件除了最后十行的其他所有日志 -
cat命令
-
功能
一次顯示整個文件。 cat filename
創(chuàng)建一個文件。 cat>filename
將幾個文件合并為一個文件。 cat file1 file2>file
-
參數(shù):
-n 由1開始對所有輸出的行數(shù)編號
-b 和-n相似,只不過對于空白行不編號
-s 當遇到有連續(xù)兩行以上的空白行,就代換為一行的空白行
-c<數(shù)目> 顯示的字節(jié)數(shù)
-n<行數(shù)> 顯示行數(shù)
-
應用
cat test.log | tail -n 1000 #輸出test.log文件最后1000行
cat -n test.log |grep "debug" #得到關鍵日志的行號
cat filename | tail -n +3000 | head -n 1000 #從第3000行開始,顯示1000行。即顯示3000~3999行
cat filename | head -n 3000 | tail -n +1000 # 顯示1000行到3000行
cat -n textfile1 > textfile2 #吧textfile1的檔案內容加上行好后輸入textfile2這個檔案里
cat -b textile1 textfile2 >> textfile3 #把textfile1和textfile2的 檔案內容加上行好(空白行不加)之后將內容附加到textfile3中
-
-
tac命令
-
功能
tac是將cat反寫過來,它的功能跟cat相反,cat是由第一行到最后一行連續(xù)顯示 ,而tac是由最后一行到第一行反向顯示。
-
-
more命令
-
功能
類似cat,不過以一頁一頁形式顯示。基本指令按空格鍵(space)往下一頁顯示,按返回鍵(back)往上一頁顯示 ,還有字符搜索功能(與vi相似)
-
參數(shù)
-num 一次顯示的行數(shù)
-d 提示使用者,在畫面下方顯示[Press space to continue,'q'to quit],如果使用者按錯鍵,則會顯示[Press 'h' for instructions.]而不是‘嗶’聲
-l 取消遇見特殊字元^L時會暫停的功能
-f 計算行數(shù)時,以實際上的行數(shù),而非自動換行過后的行數(shù)
-p 不以卷動的方式顯示每一頁,而是先清除熒幕后再顯示內容
-c 跟 -p 相似,不同的是先顯示內容在清除其他舊資料
-s 當遇到有連續(xù)兩行以上的空白行,就代換為一行的空白行
-u 不顯示下引號(根據(jù)環(huán)境變數(shù)TERM指定的terminal而有所不同)
+/pattern 在每個文檔顯示前搜尋該字串(pattern),然后從該字串之后開始顯示
+num 從第num行開始顯示
-
應用
命令 含義 more -s test.log 逐頁顯示日志,如有連續(xù)兩行以上空白行則以一行空白行顯示 more +20 test.log 從第20行開始顯示日志內容
-
如何區(qū)分前后端的BUG
日志查看法。通過查看后段服務的日志,復現(xiàn)bug時,查看日志中有沒有相關信息。如果日志沒有輸出,很可能這個功能并沒有與后端交互,也就不存在后端的問題。如果有日志輸出,可以進一步查看有無錯誤日志信息,進一步分析。
接口查看法。可以通過查看瀏覽器的接口參數(shù),再通過對比后端接口拿到的數(shù)據(jù)和前端顯示數(shù)據(jù)進行對比,來進行確認,如果數(shù)據(jù)拿錯了,頁面顯示錯誤,那么就屬于正常問題,需要先從后端入手去解決;如果數(shù)據(jù)對了,但是顯示錯了,那么就需要從前端入手去解決。
經驗之談:如果出現(xiàn)樣式的問題基本都是CSS的Bug;如果出現(xiàn)文本的問題基本上都是HTML的Bug;如果出現(xiàn)交互問題那么基本上都是Javascript的Bug
APP測試流程 參考資料
數(shù)據(jù)庫
-
<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="mysql" cid="n157" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; background-position: inherit inherit; background-repeat: inherit inherit;">select xxx from xxx where xxx limit 0,3;</pre>
-
<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="sql" cid="n170" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; background-position: inherit inherit; background-repeat: inherit inherit;">select name from student where name not in(select name from student where fenshu<=80)</pre>
- <pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="java" cid="n254" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; background-position: inherit inherit; background-repeat: inherit inherit;"> public boolean isElementPresent(By by){
try{
driver.findElement(by);
return true;
}catch(Exception e){
return false;
}
}</pre>
- <pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="java" cid="n254" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; background-position: inherit inherit; background-repeat: inherit inherit;"> public boolean isElementPresent(By by){
<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="python" cid="n271" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; background-position: inherit inherit; background-repeat: inherit inherit;">contains(a, b) #如果a中含有字符串b,則返回true,否則返回false
?
starts-with(a, b) #如果a是以字符串b開頭,返回true,否則返回false
?
ends-with(a, b) #如果a是以字符串b結尾,返回true,否則返回false</pre>| id | 唯一的 |
| --- | --- |
| name | 元素的名稱 |
| class name | 元素的類名 |
| tag name | 標簽,重復率高 |
| link text | 文本鏈接 |
| partial link text | 對文本鏈接的一種補充 |
| xpath | 相對/絕對路徑 |
| css selector | css定位 |
自動化測試面試題
軟件測試Java經典面試題
- <pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="" cid="n191" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; background-position: inherit inherit; background-repeat: inherit inherit;">1. 原子性:指一個事務要么全執(zhí)行,要么全不執(zhí)行.也就是說一個事務不可能執(zhí)行到一半就停止了.比如:你去買東西,錢付掉了,東西沒拿.這兩步必須同時執(zhí)行 ,要么都不執(zhí)行.</pre>
-