jmeter 響應結果分析一

來源:互聯網
上載者:User

標籤:

轉自:http://www.cnblogs.com/Carrie_Liang/archive/2008/11/05/1327604.html

Jmeter測試結果分析這一篇,我打算分成上下兩部分。上篇,主要講述如何使用jmeter中Assertion對結果進行簡單的分類;下篇,主要講述的是當我們拿到測試結果後,我們應該如何去看待這些測試結果。

用過LoadRunner的人都知道,LoadRunner本身提供了很多函數可以對收集回來的結果進行一些初步的分析。例如可以做到判斷返回的結果是否正確;判斷request的response time是否大於x秒之類的。相比起LoadRunner,Jmeter在這方面沒有那麼強大,但是個人認為,對於一些編程基礎不是太好的測試人員來說,Jmeter比LoadRunner易用性上面做得更出色。

Assertion--斷言,通常是用於對每一個request sampler進行額外驗證的工具。下面通過一個例子來介紹一下常用的幾個Assertions。

假設現在要進行一個登陸的壓力測試,下面是對pass的幾個定義:

1.正確login後,必須收到返回的身分識別驗證和使用者個人資訊下載的完成資訊;

2.回應時間不能超過150毫秒

3.返回的結果大小不能小於750bytes

根據以上的要求,我們在對應的request sampler下面添加了以下的Assertions。

 

A.Response Assertion

 

 Response Field to Test -- 標示被檢查對象是什嗎?

 Pattern Matching Rules -- 標明被檢查對象與驗證內容之間的關係,Contains(內含項目關聯性);Matches(匹配關係);Equals(相等關係);Not(非關係)

 Pattern to Test -- 需要驗證的內容列表

B.Duration Assertion

 

 Duration to Assert -- 允許的回應時間的最大值

C.Size Assertion

 

 Size to Assert -- 對於返回結果檔案大小的標準定義

 

二、結果分析

添加了以上的Assertions後,我運行了一次指令碼。以下是存放結果的.jtl檔案的內容:

timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,Latency
11/04/08 13:22:03,172,Do Login,200,OK,Thread Group 1-1,text,false,The operation lasted too long: It took 172 milliseconds, but should not have lasted longer than 150 milliseconds.,835,172
11/04/08 13:22:03,156,Do Login,200,OK,Thread Group 1-2,text,false,Test failed: text expected to contain /loginMsg="OK"/,633,156
11/04/08 13:22:03,156,Do Login,200,OK,Thread Group 1-3,text,false,The operation lasted too long: It took 156 milliseconds, but should not have lasted longer than 150 milliseconds.,839,156
11/04/08 13:22:03,156,Do Login,200,OK,Thread Group 1-4,text,false,The operation lasted too long: It took 156 milliseconds, but should not have lasted longer than 150 milliseconds.,836,156
11/04/08 13:22:03,78,Do Login,200,OK,Thread Group 1-5,text,true,,779,78
11/04/08 13:22:03,63,Do Login,200,OK,Thread Group 1-7,text,false,Test failed: text expected to contain /loginMsg="OK"/,570,63
11/04/08 13:22:03,141,Do Login,200,OK,Thread Group 1-6,text,false,The result was the wrong size: It was 721 bytes, but should have been greater than 750 bytes.,721,141
11/04/08 13:22:03,78,Do Login,200,OK,Thread Group 1-9,text,false,The result was the wrong size: It was 724 bytes, but should have been greater than 750 bytes.,724,78
11/04/08 13:22:03,204,Do Login,200,OK,Thread Group 1-10,text,false,The operation lasted too long: It took 204 milliseconds, but should not have lasted longer than 150 milliseconds.,1137,204
11/04/08 13:22:03,2985,Do Login,200,OK,Thread Group 1-8,text,false,Test failed: text expected to contain /loginMsg="OK"/,570,2985

我們可以看到,每一個Sampler都會經過Assertions的判斷,只要有一個不合格都會標示為False。

其實除了以上講到Assertion,jmeter還提供了其他一些比較實用的Assertion,而我在這也不一一介紹了。

有興趣的可以看一下jmeter的user manual,然後再自己動手實驗一下。

jmeter 響應結果分析一

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.