1创泄、添加測試計(jì)劃(Test Plan)并且命名為Test Plan
2、添加線程組 (Thread Group)并且命名為 Thread Group
Number of Threads(users):用戶設(shè)置線程數(shù)扼褪,即用戶數(shù)
Ram-Up Period(in seconds):XX時(shí)間內(nèi)建立全部線程
比如:Number of Threads(users):10 弓熏,Ram-Up Period(in seconds):1,即1秒內(nèi)建立10個(gè)線程场斑;
Number of Threads(users):10 漓踢,Ram-Up Period(in seconds):0,即立即建立10個(gè)線程(同時(shí)并發(fā))
Loop Count:設(shè)置循環(huán)次數(shù)
比如:Loop Count:10 漏隐,即循環(huán)10次喧半;Loop Count:forever ,一直循環(huán)
3青责、添加取樣器:
1)選擇Thread Group->Add->Sampler->Http Request
2)命名為01.login
3)web server
Protocol(協(xié)議):http
Server name or IP(域名或者IP):127.0.0.1
端口號(hào):9091
4)Http Request
Method(方法):get
path(路徑):/api/v1/user/login
Content encoding(內(nèi)容編碼):UTF-8
勾選Following redirect
勾選Use KeepAlive
5)Body data
{
"authRequest":
{
"userName": "user01",
"password": "pwd"
}
}
4挺据、添加JSON Extractor(后置處理器)
選擇Http Request->Add->Post Processors->JSON Extractor并且命名為JSON Extractor
1)Variable name :自定義參數(shù)名,引用的時(shí)候${} 格式
2)Json path expression:json表達(dá)式脖隶,根據(jù)上面的json,表達(dá)式為:$.access_token
5吴菠、添加Constant Timer(定時(shí)器)
選擇Http Request->Add->Timer->Constant Timer并且命名為Constant Timer
線程延遲,時(shí)間毫秒浩村,比如Thread Delay:300
6做葵、添加Response Assertion(斷言)
選擇Http Request->Add->Assertion->Response Assertion,并且命名為Response Assertion
判斷響應(yīng)碼是否等于200
判斷響應(yīng)內(nèi)容是否包括XX字段
7心墅、添加View Result Tree(查看結(jié)果樹)
Http Request->Add->Listener->View Result Tree并且命名為View Result Tree
請求頭(Request Headers):
請求體(Request Body):
響應(yīng)頭(Reaponse Headers):
響應(yīng)體(Response Body):
取樣器結(jié)果(Sample result):
8酿矢、Aggregate Report(查看報(bào)告)
報(bào)告中的性能指標(biāo):
Average:單個(gè)請求的平均響應(yīng)時(shí)間
Median:中位數(shù),也就是50%用戶的響應(yīng)時(shí)間
90%Line:90%的用戶響應(yīng)時(shí)間
95%Line:95%的用戶響應(yīng)時(shí)間
99%Line:99%的用戶響應(yīng)時(shí)間
Min:最小的請求響應(yīng)時(shí)間
Max:最大的請求響應(yīng)時(shí)間
Error%:錯(cuò)誤率
Throughput:吞吐量怎燥,每秒10個(gè)請求
Received KB/sec:每秒從服務(wù)器端接受到的數(shù)據(jù)量
Sent KB/sec:每秒從客戶端發(fā)送的請求數(shù)據(jù)量