If you've been following along, you'll know by now that the heart of this process lies in the Ant build.xml file. Here is the one which you can use / tweak for your purposes: https://docs.google.com/leaf?id=0Byis5NEZXwweZmQ1YjA4NjctYTgwNi00ZTU1LWExMjMtMDA3ODI1Yzg4ZjIz&hl=en_US
If you have any doubts about anything, please read through the Ant Manual.
We start off with a huge commented out section with basic information about where the instructions I followed were from http://www.programmerplanet.org/pages/projects/jmeter-ant-task.php. It also goes on to say that we should execute the commands from an Admin command prompt if possible. Then we have directions on how to run a script and a checklist of things that we should make sure of before running a test.
Please read through this and understand how to call Ant properly.
- the name of the project.
- the default target to start from (if we don't specify a target from the command line)
- the default we specify is the target named "build"
- the base directory where this file is located.
- These are the tasks which we are extending Ant with.
- name is jmeter
- classname is given -- no need to change
- resources is given -- no need to change
- Antelope If Task
- name is if
- classname is given -- no need to change
- classpath is where the antelopetask-3.2.10.jar is located -- if you have this in a different location, please specify it here.
- Set timestamp & base properties
- Current Timestamp is captured and stored in 3 variables, time, timeFull, and timeIntl. Each of them have a different format.
- 3 properties are set.
- file = *
- if file is not set when calling Ant, it will default to all the files in base directory -- all of them will be run. Note: Not specifying a file usually results in transformation failing. I haven't gotten a workaround in place for this to work correctly.
- folder = ""
- if no folder is set when calling Ant, it will be blank
- extra.properties is loaded.
- all of the parameters/properties set in the extra.properties file is loaded and populated in the build.
- Targets - these are the main containers for the various actions we want performed: start/stop Perfmon, starting Jmeter, doing a transformation, compiling the mail, sending the mail, etc.. You can read the descriptions for each target in the build.xml file.
All this script does is navigate to the BCRich http://www.bcrich.com/shape/beast/guitars-and-bass/3 -- one thread, one second rampup time, and 1 iteration.
Make sure that in extra.properties, remote = false (because we're running this off of the local machine).
- Open the command prompt (Win+R) > cmd, enter.
- Navigate to the jmeter/bin folder:
- Execute the Ant command:
ant -Dfile="BCTest" -Dfolder="BC" -Dproject="BC Project"
- -Dfile tells ant that the variable file = "BCTest".
- BCTest is located in the folder "BC" (which is what -Dfolder states).
- When we save the results and report, we want it saved in the Project folder named "BC Project" with a space.
- We should get a success message:
- We will see the "BC Project" folder created under both the reports and results folder, each of them containing a file corresponding to this run:
- Firstly since we didn't specify to Ant which target to use, it used the build target by default (look above to the Project section). If we wanted to specify a target, we'd use the argument -t targetName.
- So the build target is calling 2 other targets -- firstly it is calling jmeterStart and then transformationOld.
- Let's look under jmeterStart to see what is going on:
- First the timestamp is being captured and output to certain files in the var folder for use later.
- Next, we have an echo of the inputs.
- Next we have the jmeter section, which has the following:
- jmeter's bin location
- where the result will be saved (results\projectName\Testfilename_time.jtl)
- whether to run remotely or not (pulled from extra.properties)
- which file will be run (located in the scripts folder, under the subfolder "folderName" and including the file we specified (BCTest.jmx)
- Next, we have another timestamp being captured and output to certain files in the var folder for use later.
- Under transformationOld, we only have the XSLT instructions:
- The input file (which was the .JTL log file from JMeter).
- The output file (which is the .HTML file which gets generated).
- Which XSL file to use for the transformation (which is found in the reportXSLs folder). For this run, the uncommented xslFilename from the extra.properties is used (jmeter-results-detail-report_21).
- Whether to overwrite the report file (if for some reason there is one with the same name present) -- which is set to true (otherwise, if that case did happen, the build would fail).