JMeterTest and JMeterTestManager dependencies - jmeter

I am trying to exeucte a .jmx file through the java class, but JMeterTest and JMeterTestManager are not getting imported.
JMeter, as per my knowledge is itself a bundle of jar.
can anyone tell me if i need dependency(ies) for these two or not, iif yes the please do provide.
Thanks in advance.

As far as I can see you need to include org.wso2.carbon.automation.extensions to your project as these classes don't come with JMeter API
Check out Five Ways To Launch a JMeter Test without Using the JMeter GUI guide to get started with creating a JMeter test purely in Java. You can also use jmeter-from-code project as a reference

Related

JMeter - JSR223 PreProcessor is getting failed in the GitHub for OTP creation

I am trying to execute a .jmx script in the GitHub. The login page requires a OTP, which I am generating using org.jboss.aerogear. However, it seems when I am executing the script in GitHub the script is not generating this OTP and throwing 406 (Not Acceptable). Can anyone please guide me on this issue please.
This is running perfectly in JMeter but getting error in GitHub.
Do I need to add this specific driver and how?
Whenever you face any "error" first of all take a look at jmeter.log file, normally it contains the reason or at least a clue so you can figure out or guess the error cause. If it doesn't - increase JMeter logging verbosity for the test elements you're using.
Most probably you need to add the .jar file which provides this Totp class (along with dependencies, if any) to JMeter Classpath to JMeter installation in "Github" (whatever it means) and the error will go away

Exception: java.lang.ClassCastException: com.blazemeter.jmeter.threads.DynamicThread cannot be cast to org.apache.jmeter.samplers.SampleResult

I am currently using Blazemeter to run load (performance) tests for a Java application, but I am getting this error. When I run it locally on my machine, this error does not occur.
Under 'scenario definition' my test starts off with a standard jmeter thread group. I did a bit of searching and realised that com.blazemeter.jmeter.threads.DynamicThread comes from the CustomThreadGroups plugin, so I have also uploaded the appropriate jar file plugin jmeter-plugins-casutg-2.9.jar file.
Screenshot of scenario definition
Screenshot of error
Would just like to check if there is some other jar file that I need to upload to solve this error, or if there is another method to solve this issue? Thank you.
Normally you should raise this form of questions to BlazeMeter Support as they should have better understanding of their infrastructure.
With regards to your question itself, most probably you're suffering from a form of a Jar Hell as:
BlazeMeter uses Taurus under the hood for kicking off JMeter tests which automatically downloads JMeter Plugins so it might be the case your plugins versions clash with the plugins at their end
You need to remove one of joda-time libraries as you cannot tell for sure which one will be loaded into classpath and in case of API inconsistency you can get unpredictable errors.

JMeter Functions are not evaluating while running JMX files using Java

I am running the JMeter Scripts (.jmx files) using Java code. But it doesn's evaluate any of the JMeter Functions. I have tried multiple approaches and nothing worked.
In the logs, i could see the JMeter Functions are not evaluated. Functions like ${__property()}, {__TestPlanName()}, ${__threadNum}, ${__javaScript()} are not executed.
Did you add ApacheJMeter_functions.jar to your classpath ?
If not , please do.
Otherwise, show more about your project.

Why do the reading of local property files in JMeter require a plugin?

I was earlier looking for a way to read properties from a project-local file for use in a JMeter Test Plan.
I found a plugin that allows you to do this, but I still don't understand why this functionality isn't just supported natively by the standard distribution of JMeter. Is there a reason for this?
As described in the link you provide, the standard way to override properties files is to put them in user.properties.
Note you can also pass properties through command line option:
-q
as per http://jmeter.apache.org/usermanual/get-started.html#options
If that does not suit your requirement could you give more details about it ?

How do I write a Jmeter script without using the GUI?

Is there a way to create a JMeter test plan without going through the GUI?
I.E. can you create a script with pure code?
In a way - yes. You can create the JMX file in a text editor, but it would require knowing what every component needs.
You're better off creating in GUI mode and modifying the JMX file manually as needed.
Yes it's possible to write a test plan just by writing JAVA code.
The key classes to look into are:
StandardJMeterEngine - the main class which configures the Test Plan and executes it
HashTree - a special collection which holds Test Plan elements
A minimum of JMeter Controllers necessary to run the test.
Reference: http://blazemeter.com/blog/5-ways-launch-jmeter-test-without-using-jmeter-gui
I can write and run JMeter without GUI. JMeter use JMX file, as you can here.
Not entirely sure why you would want to write a JMX in this way? ... But yes, entirely possible if you understand the structure of the document.
You could use any basic text editor to achieve this (notepad / notepad++ for example).
A JMX file is a saved JMeter project in XML format. ~ Ref
Depending on your needs you could the browser editor from the JMeter Plugins website.
jmeter-plugins.org/editor/
Or simply save a basic JMX as a template and spend loads of time learning the structure, syntax and namings etc.

Resources