How to execute non-GUI tests from JMeter GUI?

How to execute non-GUI tests from JMeter GUI? Have you ever thought about executing JMeter tests from the GUI without utilizing the resources much? Running JMeter tests in non-GUI mode has several advantages: better results, lower resource utilization, controlling the log files, saving the type of data which are required and so on. In this article, we shall see about executing non-GUI tests from the JMeter GUI without wasting the resources in run-time. Before we begin, let us refresh about how to execute tests using non-GUI mode.

How to execute JMeter tests in non-GUI mode?

Below is the syntax to launch JMeter tests from the command prompt.

jmeter -n -t <your-test-plan.jmx> -l <your-log-file>.jtl

You can add more parameters to your command. For more details, you can refer this link. There are multiple ways of executing JMeter tests in non-GUI. You can leverage Jenkins, Maven, Ant, or custom Java code to launch JMeter tests. Now we shall see how to execute non-GUI tests from the JMeter GUI using OS Process Sampler.

Launching non-GUI tests from JMeter GUI

We are going to leverage OS Process Sampler to launch non-GUI JMeter tests without wasting resources in runtime.

What is OS Process Sampler?

OS Process Sampler in JMeter executes commands on your local machine. Whatever command you are using the command prompt window, you can use it in the JMeter test plan. E.g. if you want to launch chrome browser from JMeter test plan, you can use below parameters.

How to execute non-GUI tests from JMeter GUI? OS Process Sampler
OS Process Sampler

To add OS Process Sampler, right click on the Thread Group, Add > Sampler > OS Process Sampler. Add below configuration parameters which will invoke Chrome browser.

Command        cmd

Working Directory        <path-of-your-Chrome-browser>

Command Parameters

/C

<path-of-your-chrome.exe>

Upon executing the OS Process Sampler, in the View Results Tree > Request, you can see below output. You will not get any response in the Response data, chrome browser will be launched.

OS Process Sampler Request
OS Process Sampler Request

Now we shall see how to execute non-GUI tests from JMeter GUI?

Place the script which needs to be executed in the bin folder or your folder of your choice. Now, create a new JMeter test plan and name it as OS Process. Add the OS process sampler and View Results Tree listener, and enter the below configuration.

Command         cmd

Command Parameters

/C

jmeter -n -t DummySampler.jmx -l mytest.jtl

Leave working directory as blank if you placed your script in bin folder.

Upon executing this OS Process test plan, it will invoke your DummySampler.jmx in non-GUI mode. E.g. If the thread group of DummySampler has below configuration, then OS Process test plan will execute for 60 seconds.

Thread Group
Thread Group

In OS Process test plan > View Results Tree, you can see the output of DummySampler test plan. Below is the snapshot of the execution.

View Results Tree
View Results Tree

Test results will be logged into mytest.jtl file. To view the results of the execution, add the desired listener and map the JTL file as shown below.

Aggregated Report
Aggregated Report

Conclusion

By leveraging OS Process Sampler, it is possible to launch non-GUI tests from JMeter GUI without wasting any runtime resources. You can add more parameters to the command to customize the listeners, output file etc.

Your turn: Do you have any other way of starting JMeter tests? Please do share in the comments.

About the Author

3 thoughts on “How to execute non-GUI tests from JMeter GUI?”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Hamster - Launch JMeter Recent Test Plans SwiftlyDownload for free
+
Share via
Copy link