




已閱讀5頁,還剩33頁未讀, 繼續(xù)免費閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
Jmeter+Jenkins+maven接口自動化集成(V1.0) 目錄Jmeter+Jenkins+maven接口自動化集成1軟件版本說明3一、 JDK安裝配置3二、 Maven安裝配置31.1 Maven安裝31.2設(shè)置環(huán)境變量31.3 maven配置5三、 Maven工程搭建92.1、eclipse創(chuàng)建maven工程92.2、Maven工程子目錄創(chuàng)建102.3、Jmeter配置文件修改112.4、編輯pom.xml文件12四、 Jenkins集成193.1 Jekins 安裝193.2 Jekins 配置193.3 jenkins新建一個maven風(fēng)格的項目223.4 執(zhí)行job立即構(gòu)建27五、 附錄28軟件版本說明軟件名稱版本號下載地址JDK1.8 64bit/technetwork/java/javase/downloads/jdk8-downloads-2133151.html Jenkins 2.89.4(LTS)https:/jenkins.io/download/ maven3.3.9/download.cgitomcat8.5.27/download-80.cgi 1、 JDK安裝配置因為本次配套的Jmeter和Jenkins是基于JAVA語言開發(fā)的,需要JDK1.8支持,首選需要安裝配置JDK1.8。 JDK安裝配置詳見附錄手冊。2、 Maven安裝配置Maven是一個軟件項目管理工具,管理java項目。我們最能感受到的Maven的好處應(yīng)該是它的“自動化構(gòu)建”與“管理依賴關(guān)系”兩大功能。1.1、Maven安裝將Maven包(apache-maven-3.3.9.zip)解壓到對應(yīng)目錄,我這里放到D:java目錄下。1.2、設(shè)置環(huán)境變量新建變量名MAVEN_HOME,變量值為maven包路徑:MAVEN_HOME=D:javaapache-maven-3.3.9在PATH變量值末位追加:;%MAVEN_HOME%bin 。驗證是否配置成功打開cmd命令窗口 輸入:MVN V,窗口打印出maven版本及環(huán)境信息,說明配置成功。1.3、maven配置默認(rèn)maven是從公有倉庫下載依賴jar包,如果公司有自己的私服,最好連上,這樣下載jar會快點。 路徑:D:javaapache-maven-3.3.9confsettings.xmlMaven配置文件: !- pluginGroup | Specifies a further group identifier to use for plugin lookup. com.your.plugins - !- mirror | Specifies a repository mirror site to use instead of a given repository. The repository that | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used | for inheritance and direct lookup purposes, and must be unique across the set of mirrors. | mirrorId repositoryId Human Readable Name for this Mirror. /repo/path - alimaven aliyun maven /nexus/content/groups/public/ central repo2 central Human Readable Name for this Mirror. /maven2/ mvnrepository mvnrepository maven /maven2/ central net-cn central Human Readable Name for this Mirror. /content/groups/public/ ui central Human Readable Name for this Mirror. /maven2/ ibiblio central Human Readable Name for this Mirror. /pub/mirrors/maven2/ jboss-public-repository-group central JBoss Public Repository Group /nexus/content/groups/public !- profile | Specifies a set of introductions to the build process, to be activated using one or more of the | mechanisms described above. For inheritance purposes, and to activate profiles via | or the command line, profiles have to have an ID that is unique. | | An encouraged best practice for profile identification is to use a consistent naming convention | for profiles, such as env-dev, env-test, env-production, user-jdcasey, user-brett, etc. | This will make it more intuitive to understand what the set of introduced profiles is attempting | to accomplish, particularly when you only have a list of profile ids for debug. | | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo. jdk-1.4 1.4 jdk14 Repository for JDK 1.4 builds /maven/jdk14 default always - !- activeProfiles | List of profiles that are active for all builds. | alwaysActiveProfile anotherAlwaysActiveProfile - D:javaapache-maven-3.3.9repo D:apache-maven-3.3.9repository3、 Maven工程搭建2.1、eclipse創(chuàng)建maven工程打開eclipse,新建 File-New-Project-Maven ProjectMaven工程需要輸入groupId、artifactId、version、package。2.2、Maven工程子目錄創(chuàng)建創(chuàng)建maven工程后,在工程目錄下創(chuàng)建如下所需的文件夾 src/test/resources -存放報告模板文件 src/test/jmeter -存放jmeter配置文件及測試腳本說明:1)、這里的resource下放的是報告模板文件:jmeter-results-report-apitest.xsl,以及模板用到的資源文件:collapse.png和expand.png (D:apache-jmeter-3.3extras下復(fù)制過來的);2)、perties是jmeter配置文件(D:apache-jmeter-3.3bin下復(fù)制過來的))后綴.jmx為jmeter腳本(后續(xù)只需要把本地調(diào)試通過的jmeter腳本放入如圖這個目錄就可以了);3)、如果properties文件有過更改,則把相關(guān)的propertie文件也復(fù)制到j(luò)meter文件夾里,見上圖,否則系統(tǒng)會使用默認(rèn)的jmeter配置文件。2.3、Jmeter配置文件修改jmeter執(zhí)行結(jié)果文件默認(rèn)保存的不是xml格式,無法轉(zhuǎn)化成html格式。jmeter執(zhí)行結(jié)果文件默認(rèn)有很多執(zhí)行數(shù)據(jù)是不保存的,而測試報告需要這些數(shù)據(jù)。1) 去掉注釋(#),修改csv為xml2) 添加jtl文件結(jié)果參數(shù)jmeter.save.saveservice.data_type=truejmeter.save.saveservice.label=truejmeter.save.saveservice.response_code=true# response_data is not currently supported for CSV outputjmeter.save.saveservice.response_data=true# Save ResponseData for failed samplesjmeter.save.saveservice.response_data.on_error=falsejmeter.save.saveservice.response_message=truejmeter.save.saveservice.successful=truejmeter.save.saveservice.thread_name=truejmeter.save.saveservice.time=truejmeter.save.saveservice.subresults=truejmeter.save.saveservice.assertions=truejmeter.save.saveservice.latency=truejmeter.save.saveservice.connect_time=truejmeter.save.saveservice.samplerData=truejmeter.save.saveservice.responseHeaders=truejmeter.save.saveservice.requestHeaders=truejmeter.save.saveservice.encoding=falsejmeter.save.saveservice.bytes=truejmeter.save.saveservice.url=truejmeter.save.saveservice.filename=truejmeter.save.saveservice.hostname=truejmeter.save.saveservice.thread_counts=truejmeter.save.saveservice.sample_count=truejmeter.save.saveservice.idle_time=true2.4、編輯pom.xml文件 4.0.0 mavenjmeter maven3jmeter 0.0.1-SNAPSHOT jar maven3jmeter UTF-8 1.8 $env.WORKSPACE/Report/$env.BUILD_ID/jtl $env.WORKSPACE/Report/$env.BUILD_ID/html org.apache.maven maven-core 3.5.2 org.apache.maven maven-plugin-api 3.5.2 junit junit 3.8.1 test com.lazerycode.jmeter jmeter-maven-plugin 2.5.1 kg.apc:jmeter-plugins-json:2.6 xml true false testdemo.jmx $jmeter.result.jtl.dir jmeter-tests verify jmeter org.codehaus.mojo xml-maven-plugin 1.0.1 verify transform $jmeter.result.jtl.dir srctestresourcesjmeter-results-report-apitest.xsl $jmeter.result.html.dir html net.sf.saxon saxon 8.7 Maven配置說明:jmeter.result.jtl.dir -生成.jtl格式的測試報告路徑j(luò)meter.result.html.dir -生成.html格式的測試報告路徑j(luò)meter-maven-plugin -jmeter執(zhí)行jmx腳本核心插件jmeterExtensions -配置jmeter擴(kuò)展依賴包kg.apc:jmeter-plugins-json:2.6 -jmeter用來做json數(shù)據(jù)斷言用的插件testFilesDirectory -指定jmx文件夾testFilesIncluded -指定可執(zhí)行測試腳本testFilesExcluded -指定不可執(zhí)行測試腳本3) 調(diào)試工程,確保工程能正常運行5) 把工程代碼上傳到svn上。 其中srctestjmeter目錄下專門存放jmeter腳本,以后開發(fā)好的腳本可以上傳到這里。2.5、集成第三方擴(kuò)展插件Maven 配置pom.xml文件節(jié)點用來配置依賴包。自己公司開發(fā)的jar包沒有注冊到Maven公有倉庫,我們無法獲取到,那我們需要注冊本地就可以通過配置調(diào)用到。增加jar包,需要先將jar注冊到本地maven倉庫,打開cmd使用如下命令:mvn install:install-file -Dfile=D:javapomjmeter-plugins-json.jar -DgroupId=com.jmeter.chajian -DartifactId=jmeter-plugins-json -Dversion=2.6 -Dpackaging=jar4、 Jenkins集成3.1、Jekins 安裝這里將下載好的jenkins.war放進(jìn)tomcat/webapps目錄下,啟動tomcat的startup.bat。登入http:/localhost:8080/jenkins,進(jìn)入Jenkins。Jenkins詳細(xì)安裝說明,請參考附錄手冊。3.2、Jekins 配置l 全局工具配置路徑:系統(tǒng)管理-全局工具配置l 郵件配置路徑:系統(tǒng)管理-系統(tǒng)設(shè)置l 插件安裝路徑:系統(tǒng)管理-插件管理安裝插件:Subversion、Performance Plugin、HTML Publisher plugin、Email Extension Plugin、Email Ext Recipients Column Plugin、Groovy Label Assignment plugin。勾選如上必須要安裝的插件,點擊直接安裝。3.3、jenkins新建一個maven風(fēng)格的項目因為Jenkins安全默認(rèn)是把如下功能都關(guān)閉了,需要Groovy 插件執(zhí)行Groovy 腳本開啟。1、 javascript2、html上的內(nèi)置插件3、內(nèi)置css或從其它網(wǎng)站的css4、從其它網(wǎng)站的圖片5、AJAX構(gòu)建配置時,勾選如下Groovy腳本,每次構(gòu)建后執(zhí)行這段腳本開啟如上功能。System.setProperty(hudson.model.DirectoryBrowserSupport.CSP, )SVN配置配置jmeter接口腳本工程地址,以及鑒權(quán)用戶密碼。構(gòu)建配置定時構(gòu)建在【配置】頁面中,下拉到【構(gòu)建觸發(fā)器】,在這里有兩個可選選項,分別是“Build periodically”和“Poll SCM”,它們的特點如下:l Build periodically無論SVN中數(shù)據(jù)有無變化,均執(zhí)行定時化的構(gòu)建任務(wù)l Poll SCM定時輪詢SVN,查看SVN中是否有數(shù)據(jù)變化,如果有變化,則執(zhí)行構(gòu)建任務(wù)l 定時構(gòu)建語法* * * * *(五顆星,中間用空格隔開)第一顆*表示分鐘,取值059第二顆*表示小時,取值023第三顆*表示一個月的第幾天,取值131第四顆*表示第幾月,取值112第五顆*表示一周中的第幾天,取值07,其中0和7代表的都是周日1.每30分鐘構(gòu)建一次:H/30 * * * *2.每2個小時構(gòu)建一次H H/2 * * *3.每天早上8點構(gòu)建一次0 8 * * *4.每天的8點,12點,22點,一天構(gòu)建3次0 8,12,22 * * *(多個時間點,中間用逗
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 中國房產(chǎn)代理行業(yè)市場深度分析及發(fā)展前景預(yù)測報告(2020-2025年)
- 中國手機(jī)移動搜索行業(yè)市場深度評估及投資戰(zhàn)略規(guī)劃報告
- 2024-2030全球叉車維修升降機(jī)行業(yè)調(diào)研及趨勢分析報告
- 中國快卸銷行業(yè)市場調(diào)研及未來發(fā)展趨勢預(yù)測報告
- 2024年全球及中國伺服電機(jī)維修行業(yè)頭部企業(yè)市場占有率及排名調(diào)研報告
- 2025年中國油灰刀行業(yè)發(fā)展前景預(yù)測及投資方向研究報告
- 中國醫(yī)藥批發(fā)市場調(diào)查研究及行業(yè)投資潛力預(yù)測報告
- 2025年中國礬土水泥行業(yè)市場發(fā)展監(jiān)測及投資戰(zhàn)略咨詢報告
- 2021-2026年中國預(yù)制構(gòu)件行業(yè)發(fā)展監(jiān)測及投資戰(zhàn)略規(guī)劃研究報告
- 中國真空泵制造行業(yè)市場深度分析及投資戰(zhàn)略規(guī)劃研究報告
- 2021年中國美術(shù)學(xué)院輔導(dǎo)員招聘考試題庫及答案解析
- 初中道德與法治學(xué)科教學(xué)經(jīng)驗交流
- 申辦出入境證件的函
- 安全評估收費指導(dǎo)意見
- DB34-T 4289-2022城鎮(zhèn)檢查井蓋安裝管理技術(shù)規(guī)程
- 年產(chǎn)3萬噸硫酸鉀,1.8萬噸副產(chǎn)工業(yè)鹽項目建設(shè)可行性研究報告
- 貴州省建筑與裝飾工程計價定額(2023版)
- 發(fā)證機(jī)關(guān)所在地區(qū)代碼表
- 征地補(bǔ)償數(shù)據(jù)庫建設(shè)技術(shù)方案
- 水下封底混凝土計算及施工
- YY∕T 1784-2021 血氣分析儀
評論
0/150
提交評論