Jmeter with ant - reports creation - ant

I am trying to create report using ant in jmeter, meaning the full report.
I downloaded ant and it is installed as expected.
first I want to understand if ant command need to perform after test plan ran in the past? meaning it is offline process that creates the html reports? after the test plan finished?
Or is it command that actually used to run the test plan and create the html, meaning I do not need to run jmeter before?.
I used this command
jmeter -n -t C:\JMETER\Framework\Test_Fragment\Kung_Fu.jmx -l C:\Users\stackoverflow\Desktop\Jmeter_reports\results22_05_2018.csv
to run jmeter from command line, and create csv, so do I need two commands? one for creating csv and one for the ant? and if I create the csv where can I find the jtl of the testplan.
Name of test plan kung_fu
name of csv results22_05_2018.csv
what are the processes to run he ant, since I rename the Kung_Fu.jmx to test.jmx and put it in extras folder and when I command ant, it says test.jtl is not found.
can someone give a full explanation about the whole process

Rename results22_05_2018.csv into results22_05_2018.jtl and copy it to "extras" folder of your JMeter installation
Execute the following command in "extras" folder of your JMeter installation:
ant -Dtest=results22_05_2018 xslt-report
HTML report will be available as results22_05_2018.html
For more details see:
build.xml - reference Ant build file, by default it:
looks for Test.jmx file in the current folder
executes it and stores the result into Test.jtl file
applies XSLT transformation to the Test.jtl file and generates HTML file out of it.
JMeter Ant Task
Five Ways To Launch a JMeter Test without Using the JMeter GUI

Related

Jtl file is empty when running Jmeter using ant

I am trying to run Jmeter with ant, (since I want to display the results of test, with all the steps).
The issue is that after I managed to run the command the Jtl file is empty, I am trying to run the basic test.jmx default test.
I run the command ant -Detest=Test run
the build is successful but the jtl results are empty. moreover it is finished after one second, while if I run via UI mode it should take more time.
Can someone please advise how to use ant with Jmeter, or how to get fully reports like in csv in html out put?
[][build results]
[][build.xml from ant\bin location]
[][location of test.jtl results file]
[][results are empty]
Most probably something is wrong with your JMeter test itself, i.e.
JMeter failed to start (installation or configuration issues)
it has 0 threads in Thread Group
there is an If Controller condition which prevent test execution
the test relies on a JMeter Plugin which is not installed
etc.
So I would recommend amending your build.xml file and enable writing JMeter log file by adding the next line to <jmeter> section: jmeterlogfile="${testpath}/jmeter-ant.log >
So it would look like
<jmeter
jmeterhome="${jmeter.home}"
testplan ="${testpath}/${test}.jmx"
resultlog="${testpath}/${test}.jtl"
jmeterlogfile="${testpath}/jmeter-ant.log>
When you run your test one more time you should see jmeter-ant.log file in the folder where your .jmx file lives.
More information: JMeter Ant Task

how to run jmeter with ANT

I want to display Jmeter results via html. the html dashboard is not informative enough, so I want to use the ant solution.
I installed ant as expected
I took my testplan.jmx and copy it to
C:\Jmeter_4.0\apache-jmeter-4.0\extras
I changet the testplan.jmx to Test.jtl
I entered to cmd cd C:\Jmeter_4.0\apache-jmeter-4.0\extras
I entered ant and press enter
the test plan always take 20 minutes and in ant 12 second that is very stange since I have delay of 15 minutes.
I opened Test.html and instead of seeing results I saw the test plan as xml. and jmeter not start or even worked. what I am missing , why ant not runnung the testplan. the results is not even html see pic
You need to rename your file to Test.jmx, not to Test.jtl.
If there is a Test.jtl file already there - you will need to delete it as by default JMeter Ant Task will add new results into existing Test.jtl file which is not something you should be looking for.
There is another option: you can generate Ant-style HTML report from .jtl results file.
Execute your script "normally" in non-GUI mode like:
jmeter -n -t testplan.jmx -l Test.jtl
Copy Test.jtl file to "extras" folder of your JMeter installation
Execute ant xslt-report command.
That's it, you should see the results in HTML form as Test.html file
See Five Ways To Launch a JMeter Test without Using the JMeter GUI article for more information on different ways of running a JMeter test from command line and from Java code.

Jenkins TestNG plugin does not fetch results from the test-results.xml file

In my project workspace, the test-results.xml file exists inside the target\surefire-reports\testng-results.xml directory. But Jenkins fails to read the XML file and gives below error on console.
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern: **\target\surefire-reports\testng-results.xml
Did not find any matching files.
To ensure the file isn't too old, I had checked that the test-results.xml (and other files) belong to the latest test run. The Jenkins server is running on Ubuntu 14.04 LTS.
I'm running my tests in this manner: My project root directory has a run_tests.sh script which looks like this:
#!/bin/bash
if [ "$1" = "" ]; then
echo "Please provide a valid suite XML file name."
else
mvn clean
mvn compile
mvn clean test -Dsurefire.suiteXmlFiles="$1"
fi
I just pass the suite XML file name as a parameter to this script in Jenkins (execute shell).
Please help.
I found the solution for this.
Go to Configure of your Job
in General Tab, you may find
Advanced Button, Click on this
Check the check box of "Use custom
workspace", under this you see the Directory text box, here you copy
your Selenium Workspace Folder, for example mine is
"E:\eclipse\eclipse-workspace\WebDriveTest\"
Scroll down the page
under the Post-build Actions, Publish TestNG Results, TestNG XML
report pattern : give like this
"**/target/surefire-reports/testng-results.xml" (check this path in
the same workspace).
I hope this will help you!.
You should be using / instead of \ (since you mentioned that your Jenkins is running on a UNIX box)
Krishnan, in the testng-users Google Group, pointed out that it could be an issue with my Jenkins project workspace, and it was the same.
I changed the default workspace in my Jenkins project.
So I've added the path "$HOME/myWorkspace/myProject/" in my Jenkins project workspace, and "**/target/surefire-reports/testng-results.xml" in my TestNG setting in the same Jenkins project, and it works!
Thank you Krishan for your help.
Please see my answer in another post here, it should be very clear.
In short, it is caused by the current directory was changed to the default Jenkins workspace, you need set your custom workspace in the Job's Config.
I agree with Krishnan Mahadevan usage of '\' instead of '/' while providing the path for TestNG Report also solved my problem.
Extremely important thing to note here:
When providing path for Root POM in the build section '\' is used
C:\Users\harsh\eclipse-workspace\ProjTwo3\pom.xml
When providing path for TestNG XML report pattern in Publish TestNG Result section
'/' is used
C:/Users/harsh/eclipse-workspace/ProjTwo3/target/surefire-reports/testng-results.xml
Console Output:
channel stopped
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern:
C:/Users/harsh/eclipse-workspace/ProjTwo3/target/surefire-reports/testng-results.xml
Saving reports...
Processing 'C:\Users\harsh.jenkins\jobs\MyApplication\builds\12\testng\testng-results.xml'
11.688312% of tests failed, which exceeded threshold of 0%. Marking build as UNSTABLE

How to use Apache Ant in Jmeter?

How to generate Html reports from using Apache ant in Jmeter.
Please attach screenshots
There won't be too much screenshots, however I believe the answer will still be helpful
Install Apache Ant. Make sure that /bin folder of Ant installation is in your PATH
Go to "extras" folder of your JMeter installation in command propmt.
Type ant
If everything goes well you should see "BUILD SUCCESSFUL" message
Ant will generate 2 artifacts:
Test.jtl - XML file with results
Test.html - HTML wile with results which can be viewed in browser
If steps 1-5 are successful you can now replace /extras/Test.jmx with your own JMeter test, delete Test.jtl file and execute step 3 for your test script.
See following references:
/extras/build.xml Ant build file
JMeter Ant Task manual
Five Ways To Launch a JMeter Test without Using the JMeter GUI guide which includes launching JMeter via Ant.
JMeter produces the result in XML format. You need an XSLT file to convert this to a nice HTML.
This site has the detailed steps on running JMeter tests with ANT + creating HTML reports + Creating charts.
http://www.testautomationguru.com/jmeter-continuous-performance-testing-part1/

Netbeans build.xml to execute when using Ant

I'm relatively new to using build files and Ant to compile and execute from a command line so i wanted to know how it would be possible to modify the build-impl.xml file auto generated from netbeans so that after it compiles it also executes the program.
Currently when i type just "ant" in the command window where the build.xml file is listed it compiles and etc but then says
-do-jar-copylibs:
[copylibs] Nothing to copy.
[echo] To run this application from the command line without Ant, try:
[echo] java -jar "C:\Users\Eric\Documents\Word Documents\Java Test Code\NetbeansVersion\Cops\dist\Cops.jar"
I can run that command and it will run fine, but i want the program to execute by just typing ant.
The build.xml file - Pastebin
Build-impl.xml file - Pastebin
There are a couple "tasks" available in ant that you could use to accomplish this.
You can use either of these:
Java Task,
Exec Task
Those documentation pages provide examples as well. Before you go there though, you might want to start at the basic manual to get an idea of the structure of an ant build file to determine where and how you want to add this execution step in.
It feels a little "off" to me to have your build script executing the program, but I'm sure you've got a reason, so I might suggest adding a new target that does the build steps and then also runs this command to kick off the program. That way you've still got the option of running the build without running the program.

Resources