Alexa, tell VoxSnap to play posts from BlazeMeter
The JMeter GUI should only be used for test development or debugging. We do not advise using JMeter in GUI mode if you are initiating an actual load test, even with JMeter's updated GUI in its later versions. This article highlights the most commonly used options for unattended test execution – from simple JMeter command-line mode to the use of the BlazeMeter API to initiate a 1,000-user load test without even opening a browser.
1. USE THE COMMAND LINE
You can execute JMeter test from the command line. It is as simple as
jmeter -n -t your_script.jmx
Where:
● -n - tells JMeter to run in non-GUI mode
● -t - specifies the path to source .jmx script to run
We often use these minimal options in combination with -l switch, which tells JMeter where to store test results. If a results file already exists, it will be appended. After the test execution you can open the resulting CSV file with any Listener, Excel, or any other analytics software.
2. USE APACHE ANT
You can integrate JMeter with Apache Ant using the JMeter Ant Task. Once you have properly formed an Ant build XML configuration file, you can initiate the JMeter script using Ant. (To see a sample JMeter test plan, look in the /extras folder of your JMeter installation. It’s called Test.jmx. The example build.xml Ant configuration file is in the same location.)
Assuming Apache Ant is properly installed, go to the /extras folder and invoke an Ant command there. Ant looks for a build.xml file under the current directory and processes it.
Ant picks up the Test.jmx file, executes it, and generates an easily-readable HTML report.
3. USE APACHE MAVEN
You can integrate JMeter with Apache Maven using the JMeter Maven Plugin. Maven uses a pom.xml file where POM stands for “Project Object Model” as a fundamental unit of work to be done. To enable JMeter integration, you must add a build event to pom.xml.
To kick off the test, type mvn verify or mvn install in the root folder. You should see a Maven output in the command prompt.
For basic and advanced configuration options, consult the Maven JMeter Plugin Project Wiki.
The HTML report that’s created is identical to the one generated by Apache Ant.
4. RUN A JMETER TEST THROUGH A PROGRAM (FROM JAVA CODE)
Another option is to run a JMeter script from Java code. To execute an existing JMeter test from Java code or to create one through programming, basic Java knowledge is a must, and the following are mandatory:
1. Have JMeter installed somewhere
2. Have the required JMeter jars from /lib and especially /lib/ext folders of your JMeter installation in your project or module class path.
4.2 Running an existing JMeter Test from Java code
The main class, …