1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <!--
3
+ Licensed to the Apache Software Foundation (ASF) under one or more
4
+ contributor license agreements. See the NOTICE file distributed with
5
+ this work for additional information regarding copyright ownership.
6
+ The ASF licenses this file to You under the Apache License, Version 2.0
7
+ (the "License"); you may not use this file except in compliance with
8
+ the License. You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ -->
18
+ <project name =" ant-jmeter" default =" all" >
19
+ <description >
20
+
21
+ Sample build file for use with ant-jmeter.jar
22
+ See http://www.programmerplanet.org/pages/projects/jmeter-ant-task.php
23
+
24
+ To run a test and create the output report:
25
+ ant -Dtest=script
26
+
27
+ To run a test only:
28
+ ant -Dtest=script run
29
+
30
+ To run report on existing test output
31
+ ant -Dtest=script report
32
+
33
+ The "script" parameter is the name of the script without the .jmx suffix.
34
+
35
+ Additional options:
36
+ -Dshow-data=y - include response data in Failure Details
37
+ -Dtestpath=xyz - path to test file(s) (default user.dir).
38
+ N.B. Ant interprets relative paths against the build file
39
+ -Djmeter.home=.. - path to JMeter home directory (defaults to parent of this build file)
40
+ -Dreport.title="My Report" - title for html report (default is 'Load Test Results')
41
+
42
+ Deprecated:
43
+ -Dformat=2.0 - use version 2.0 JTL files rather than 2.1
44
+
45
+ </description >
46
+ <property name =" testpath" value =" ${ basedir } " />
47
+ <property name =" jmeter.home" value =" ${ basedir } /../../jmeter-3.0" />
48
+ <property name =" report.title" value =" 测试报告" />
49
+ <property name =" ReportName" value =" 首页接口测试报告" />
50
+
51
+ <tstamp >
52
+ <format property =" time" pattern =" yyyyMMddhhmm" />
53
+ </tstamp >
54
+
55
+ <!-- Should report include response data for failures? -->
56
+ <property name =" show-data" value =" n" />
57
+
58
+ <property name =" format" value =" 2.1" />
59
+
60
+ <condition property =" style_version" value =" " >
61
+ <equals arg1=" ${ format } " arg2=" 2.0" />
62
+ </condition >
63
+
64
+ <condition property =" style_version" value =" _21" >
65
+ <equals arg1=" ${ format } " arg2=" 2.1" />
66
+ </condition >
67
+
68
+ <condition property =" funcMode" >
69
+ <equals arg1=" ${ show-data } " arg2=" y" />
70
+ </condition >
71
+
72
+ <condition property =" funcMode" value =" false" >
73
+ <not >
74
+ <equals arg1=" ${ show-data } " arg2=" y" />
75
+ </not >
76
+ </condition >
77
+
78
+ <!-- Allow jar to be picked up locally -->
79
+ <path id =" jmeter.classpath" >
80
+ <fileset dir =" ${ jmeter.home } /extras" >
81
+ <include name =" ant-jmeter*.jar" />
82
+ </fileset >
83
+ </path >
84
+
85
+ <taskdef
86
+ name =" jmeter"
87
+ classpathref =" jmeter.classpath"
88
+ classname =" org.programmerplanet.ant.taskdefs.jmeter.JMeterTask" />
89
+
90
+ <target name =" all" depends =" run,report" />
91
+
92
+ <target name =" run" >
93
+ <echo >funcMode = ${ funcMode } </echo >
94
+ <delete verbose =" true" includeemptydirs =" true" >
95
+ <fileset dir =" ${ testpath } /htmls" >
96
+ <include name =" **/*" />
97
+ </fileset >
98
+ </delete >
99
+ <delete verbose =" true" includeemptydirs =" true" >
100
+ <fileset dir =" ${ testpath } /jtls" >
101
+ <include name =" **/*" />
102
+ </fileset >
103
+ </delete >
104
+
105
+ <!-- <delete file="${testpath}/htmls/*.html"/>
106
+ <delete file="${testpath}/jtls/*.jtl"/>
107
+ -->
108
+ <jmeter
109
+ jmeterhome =" ${ jmeter.home } "
110
+ resultlog =" ${ testpath } /jtls/${ ReportName } .jtl"
111
+ mailSubject=" 网站接口测试报告概要"
112
+
113
+ <!--
114
+ testplan ="${testpath}/jmxs/Test.jmx"
115
+
116
+ <jvmarg value="-Xincgc"/>
117
+ <jvmarg value="-Xmx128m"/>
118
+ <jvmarg value="-Dproperty=value"/>
119
+ <jmeterarg value="-qextra.properties"/>
120
+ -->
121
+ <!-- Force suitable defaults -->
122
+ <jvmarg value =" -Dfile.encoding=UTF-8" />
123
+ <testplans dir =" ${ testpath } /jmxs" includes =" *.jmx" />
124
+ <property name =" jmeter.save.saveservice.response_data" value =" false" />
125
+ <property name =" jmeter.save.saveservice.samplerData" value =" true" />
126
+ <property name =" jmeter.save.saveservice.responseHeaders" value =" true" />
127
+ <property name =" jmeter.save.saveservice.requestHeaders" value =" true" />
128
+ <property name =" jmeter.save.saveservice.encoding" value =" true" />
129
+ <property name =" jmeter.save.saveservice.url" value =" true" />
130
+ <property name =" jmeter.save.saveservice.filename" value =" true" />
131
+ <property name =" jmeter.save.saveservice.hostname" value =" true" />
132
+ <property name =" jmeter.save.saveservice.thread_counts" value =" true" />
133
+ <property name =" jmeter.save.saveservice.sample_count" value =" true" />
134
+ <property name =" jmeter.save.saveservice.idle_time" value =" true" />
135
+ <property name =" jmeter.save.saveservice.output_format" value =" xml" />
136
+ <property name =" jmeter.save.saveservice.assertion_results" value =" all" />
137
+ <property name =" jmeter.save.saveservice.bytes" value =" true" />
138
+ <property name =" file_format.testlog" value =" ${ format } " />
139
+ <property name =" jmeter.save.saveservice.response_data.on_error" value =" true" />
140
+ </jmeter >
141
+ </target >
142
+
143
+
144
+ <property name =" lib.dir" value =" ${ jmeter.home } /lib" />
145
+
146
+ <!-- Use xalan copy from JMeter lib directory to ensure consistent processing with Java 1.4+ -->
147
+ <path id =" xslt.classpath" >
148
+ <fileset dir =" ${ jmeter.home } /lib" includes =" xalan*.jar" />
149
+ <fileset dir =" ${ jmeter.home } /lib" includes =" serializer*.jar" />
150
+ </path >
151
+
152
+ <target name =" report" depends =" xslt-report,copy-images" >
153
+ <echo >Report generated at ${ report.datestamp } </echo >
154
+ </target >
155
+
156
+ <target name =" xslt-report" depends =" _message_xalan" >
157
+ <tstamp ><format property =" report.datestamp" pattern =" yyyy/MM/dd HH:mm" /></tstamp >
158
+ <xslt
159
+ classpathref =" xslt.classpath"
160
+ force =" true"
161
+ in =" ${ testpath } /jtls/${ ReportName } .jtl"
162
+ out =" ${ testpath } /htmls/${ ReportName } .html"
163
+ style =" ${ jmeter.home } /extras/jmeter.results.shanhe.me.xsl" >
164
+ <param name =" showData" expression =" ${ show-data } " />
165
+ <param name =" titleReport" expression =" ${ report.title } " />
166
+ <param name =" dateReport" expression =" ${ report.datestamp } " />
167
+ </xslt >
168
+ </target >
169
+
170
+ <!-- Copy report images if needed -->
171
+ <target name =" copy-images" depends =" verify-images" unless =" samepath" >
172
+ <copy file =" ${ basedir } /expand.png" tofile =" ${ testpath } /htmls/expand.png" />
173
+ <copy file =" ${ basedir } /collapse.png" tofile =" ${ testpath } /htmls/collapse.png" />
174
+ </target >
175
+
176
+ <target name =" verify-images" >
177
+ <condition property =" samepath" >
178
+ <equals arg1=" ${ testpath } " arg2=" ${ basedir } " />
179
+ </condition >
180
+ </target >
181
+
182
+ <!-- Check that the xalan libraries are present -->
183
+ <condition property =" xalan.present" >
184
+ <and >
185
+ <!-- No need to check all jars; just check a few -->
186
+ <available classpathref =" xslt.classpath" classname =" org.apache.xalan.processor.TransformerFactoryImpl" />
187
+ <available classpathref =" xslt.classpath" classname =" org.apache.xml.serializer.ExtendedContentHandler" />
188
+ </and >
189
+ </condition >
190
+
191
+ <target name =" _message_xalan" unless =" xalan.present" >
192
+ <echo >Cannot find all xalan and/or serialiser jars</echo >
193
+ <echo >The XSLT formatting may not work correctly.</echo >
194
+ <echo >Check you have xalan and serializer jars in ${ lib.dir } </echo >
195
+ </target >
196
+
197
+ </project >
0 commit comments