Jforum_看帖_回帖_发帖的测试用例
load test "Test Plan" (globalVars:[], executeTearDownThreadsOnShutdown: ) Comments: run "Reply Topic" ( threads: "1", loops: "1", ramp-up: "1" ) handle cookies "HTTP Cookie Manager" (clearOnEachIteration: false, policy: "rfc2109", cookies: [ ]) globalVars "User Defined Variables" ([ "URL" = "127.0.0.1" , "PORT" = "8080" ]) add headers "HTTP Header Manager" (headers:[ {"User-Agent"= "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; max-meeting; max-meeting-user)" , {"Accept"= "application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, */*" , {"Accept-Language"= "zh-CN" ]) LoopController "Login" read csv into vars "CSV Data Set Config" (file: "D:/jemeter5.4.1/apache-jmeter-5.4.1/script/userAcct.dat", vars:"loginAcct,pwd", sharing:"shareMode.all", recycleOnEof:true, stopThreadOnEof:false ) http request "进入登陆页面" (method: "GET", url: " http://${URL}:${PORT}//jforum-2.1.9/user/login.page", body: [ ] , upload-files: [ ] ) assert as "响应断言" that (response_code) is equal to [ "200" ]) http request "Session验证" (method: "GET", url: " http://${URL}:${PORT}//jforum-2.1.9/ping_session.jsp", body: [ ] , upload-files: [ ] ) SyncTimer "Synchronizing Timer" (disabled) http request "登陆" (method: "POST", url: " http://${URL}:${PORT}//jforum-2.1.9/jforum.page", body: [ "module"= "user" , "action"= "validateLogin" , "username"= "${loginAcct}" , "password"= "${pwd}" , "redirect"= "" , "login"= "登入" ] , upload-files: [ ] ) extract-regexp "获取版块ID" using response body (exportedVar: "moduleId" regex: "", template: "", default: "", matchNr: "") Comments: <a class="forumlink" href="/jforum-2.1.9/forums/show/1.page" assert as "检查登陆" that (response_data) contains [ "jforum-2.1.9/forums/show" ]) Comments: jforum-2.1.9/forums/list.page http request "Session验证" (method: "GET", url: " http://${URL}:${PORT}//jforum-2.1.9/ping_session.jsp", body: [ ] , upload-files: [ ] ) think-time Constant "固定定时器" (const:100ms) SyncTimer "Synchronizing Timer" (disabled) if "进入版块-浏览操作" (condition: "${moduleId_g1}>=1 && ${moduleId_g1} != "\${moduleId_g1}"") http request "进入版块" (method: "GET", url: " http://${URL}:${PORT}//jforum-2.1.9/forums/show/${moduleId_g1}.page", body: [ ] , upload-files: [ ] ) Comments: moduleId_g1 extract-regexp "获取帖子ID" using response body (exportedVar: "topicId" regex: "", template: "", default: "", matchNr: "") Comments: <a href="/jforum-2.1.9/posts/list/120803.page"> assert as "是否成功进入版块" that (response_data) contains [ "jforum-2.1.9/forums/show/([1-9]\d*).page" ]) Comments: jforum-2.1.9/forums/show/4.page http request "Session验证" (method: "GET", url: " http://${URL}:${PORT}//jforum-2.1.9/ping_session.jsp", body: [ ] , upload-files: [ ] ) if "浏览操作-浏览帖子" (condition: "${topicId_g1}>=1 && ${topicId_g1} != "\${topicId_g1}"") http request "浏览帖子" (method: "GET", url: " http://${URL}:${PORT}//jforum-2.1.9/posts/list/${topicId_g1}.page", body: [ ] , upload-files: [ ] ) Comments: http://127.0.0.1:8089/jforum-2.1.9/posts/list/120867.page assert as "是否浏览成功" that (response_data) contains [ "posts/list/([1-9]\d*).page" ]) Comments: http://127.0.0.1:8089/jforum-2.1.9/posts/list/120737.pagejforum-2.1.9/posts/list/120870.page#120962 http request "Session验证" (method: "GET", url: " http://${URL}:${PORT}//jforum-2.1.9/ping_session.jsp", body: [ ] , upload-files: [ ] ) http request "进入回帖页面" (method: "GET", url: " ://${URL}:${PORT}//jforum-2.1.9/posts/reply/0/${topicId_g1}.page", body: [ ] , upload-files: [ ] ) assert as "是否进入回帖页面成功" that (response_code) is equal to [ "200" ]) http request "Session验证" (method: "GET", url: " http://${URL}:${PORT}//jforum-2.1.9/ping_session.jsp", body: [ ] , upload-files: [ ] ) http request "回复帖子" (method: "POST", url: " http://${URL}:${PORT}//jforum-2.1.9/jforum.page", body: [ "action"= "insertSave" , "addbbcode24"= "#444444" , "addbbcode26"= "12" , "attach_sig"= "on" , "comment_0"= "" , "delete_attach"= "" , "disable_html"= "on" , "edit_attach_ids"= "" , "forum_id"= "1" , "helpbox"= "提示: 格式可以快速套用在选择的文字上" , "message"= "${__RandomString(5,fjafdsafda,)}" , "module"= "posts" , "notify"= "on" , "preview"= "0" , "start"= "0" , "subject"= "回复:Support JForum - Please read" , "topic_id"= "2" , "topic_type"= "2" , "total_files"= "1" ] , upload-files: [ {param="file_0", path="C:\Users\Administrator\Desktop\jforum配置.png", mime-type="image/png"} ] ) Comments: http://127.0.0.1:8080/jforum-2.1.9/jforum.page assert as "是否回帖成功" that (response_code) is equal to [ "200" ]) http request "Session验证" (method: "GET", url: " http://${URL}:${PORT}//jforum-2.1.9/ping_session.jsp", body: [ ] , upload-files: [ ] ) http request "发帖子" (method: "POST", url: " http://${URL}:${PORT}//jforum-2.1.9/jforum.page", body: [ "action"= "insertSave" , "module"= "posts" , "preview"= "0" , "forum_id"= "1" , "start"= "" , "subject"= "1234" , "addbbcode24"= "#444444" , "addbbcode26"= "12" , "helpbox"= "文字颜色: [color" , "message"= "1234" , "disable_html"= "on" , "attach_sig"= "on" , "notify"= "on" , "topic_type"= "0" , "poll_label"= "" , "poll_option"= "" , "poll_option_count"= "1" , "poll_option_1"= "" , "poll_length"= "0" , "edit_attach_ids"= "" , "delete_attach"= "" , "total_files"= "1" , "comment_0"= "" ] , upload-files: [ {param="file_0", path="C:\Users\Administrator\Desktop\jforum配置.png", mime-type="image/png"} ] ) Comments: http://127.0.0.1:8080/jforum-2.1.9/jforum.page assert as "是否发帖成功" that (response_code) is equal to [ "200" ]) write samples "察看结果树" DebugSampler "Debug Sampler" write samples "Summary Report" write samples "Aggregate Report"