Jenkins+ant+jmeter Interface Automation Integration Test Example

Source: Internet
Author: User
Tags echo message

Jenkins+ant+jmeter Interface Automation Integration Test Example

First, Jenkins installation configuration

1, installation configuration jdk1.6+ environment variables;

2, download Jenkins.war, put in C:\jenkins directory, directory location arbitrary;

Jenkins Startup method:

CMD enters the Jenkins directory and executes Java-jar Jenkins.war

Browser input: localhost:8080 can access Jenkins to indicate a successful configuration;

Second, ant installation configuration

1, download apache-ant-1.9.6, put e-disk, such as E:\apache-ant-1.9.6, directory location arbitrary

2. Configure Environment variables:

Ant_home E:\apache-ant-1.9.6

Path E:\apache-ant-1.9.6

Classpath E:\apache-ant-1.9.6

3, verify the ant configuration is successful;

CMD to enter the ANT hint below indicates the configuration was successful:

Buildfile:build.xml does not exist!

Build failed

Third, configure the XML file

1, jmeter directory location: D:\tools\apache-jmeter-2.11, in the JMeter set up the demo folder, the demo to create build.xml files, you need to configure JMeter directory, generate report path, report format and script directory, The contents are as follows:

<?xml version= "1.0" encoding= "UTF8"?>

<project name= "Ant-jmeter-test" default= "Run" basedir= "." >

<tstamp>

<format property= "Time" pattern= "Yyyymmddhhmm"/>

</tstamp>

<property environment= "env"/>

<property name= "ReportName" value= "Testreport"/>

<!--local Jmeter directory--

<property name= "Jmeter.home" value= "D:\tools\apache-jmeter-2.11"/>

<!--jmeter path to generate reports--

<property name= "Jmeter.result.dir" value= "${env. Workspace}/results/${env. build_id} "/>

<!--generate JTL, HTML-formatted reports to build ID names --

<property name= "Jmeter.result.jtlName" value= "${env. Workspace}/results/${env. Build_id}/${env. Build_id}.jtl "/>

<property name= "Jmeter.result.htmlName" value= "${env. Workspace}/results/${env. Build_id}/${env. Build_id}.html "/>

<target name= "Run" >

<echo message= "Start ..."/>

<antcall target= "clean"/>

<antcall target= "Test"/>

<antcall target= "Report"/>

</target>

<target name= "clean" >

<mkdir dir= "${env. Workspace}/results/${env. build_id} "/>

</target>

<target name= "Test" >

<taskdef name= "JMeter" classname= "Org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"/>

<jmeter jmeterhome= "${jmeter.home}" resultlog= "${jmeter.result.jtlname}" >

<!--Declare the script to run and the JMeter script in this directory--

<testplans dir= "D:\tools\apache-jmeter-2.11\demo" includes= "Login.jmx"/>

<property name= "Jmeter.save.saveservice.output_format" value= "xml"/>

</jmeter>

</target>

<target name= "Report" >

<xslt in= "${jmeter.result.jtlname}"

out= "${jmeter.result.htmlname}"

style= "${jmeter.home}/extras/jmeter-results-detail-report_21.xsl"/>

</target>

</project>

Which ${env. Workspace}/results/${env. Build_id}/${env. BUILD_ID}.JTL and

${env. Workspace}/results/${env. Build_id}/${env. The report location generated by build_id}.html is:

In the C:\Users\Administrator\.jenkins\jobs\test\workspace\results directory, each time Jenkins is built, a new build number catalog and results report are generated;

2, put the JMeter test script into the demo directory, of course, in other locations can also, build.xml need to configure JMeter script storage path corresponding location.

Iv. Construction of Jenkins Project

1, start Jenkins, browser input localhost:8080 into the management interface, click New;

2, enter the project name: Test_demo, choose to build a free-style software project, click OK;

3, tick discard the old build, configured as follows:

4, build, increase the build step select Invoke Ant,targets input run, click Advanced, build File path to enter Build.xml, save;

5, return to the homepage can see the new project, click Build to launch the test;

6, the left can see the start status and construction number;

7, enter the building number directory C:\Users\Administrator\.jenkins\jobs\Test_demo\workspace\results\60 can view the JMeter script run report;

V. Use TOMCAT to view test results:

1, modify the Build.xml file HTML report generated by the path, the reports file in the demo path, modified as follows:

<property name= "Jmeter.result.htmlName" value= "report/report.html"/>

2. Virtual directory configured as Tomcat

A, configuration Server.xml

Open the/conf/server.xml file under the Tomcat directory and add the following between the host tags.

<context path= "/test/report" docbase= "/test/report" reloadable= "true" debug= "0"/>

Path: Project name + file path, when accessing files in the path directory, actually access files under the Docbase directory.

DocBase: The true path of the file. Note that if there is a file long pass, the uploaded file path is set to Docbase instead of path.

B. Modify the Tomcat port

Tomcat port 8080 is already occupied by Jenkins, you need to modify the port, open the/conf/server.xml file under the Tomcat directory, change connector port to 8088

<connector port= "8088" protocol= "http/1.1"

connectiontimeout= "20000"

redirectport= "8443"/

C. Configure Web. xml

Open the/conf/web.xml under the Tomcat directory and set the listings property to True.

<servlet>

<init-param>

<param-name>listings</param-name>

<param-value>true</param-value>

</init-param>

<load-on-startup>1</load-on-startup>

</servlet>

Access the Localhost:8088/report to access the results report.

Of course, Jenkins is more than that, and there are plenty of powerful places for you to discover.

Jenkins+ant+jmeter Interface Automation Integration Test Example

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.