I'm looking to abstract the sequence of REST calls for complicated behaviors in my company's app into a series of classes that are instantiated as needed and the methods would effectively create the sequence of HTTP request calls. It's my hope that doing this would make the tests more compact and readable (as well as providing more reusable code). I would need to utilize the StandardJmeterEngine and export the test to JMX format after the HashTree test plan is created.
To cut on development time, I'm hoping to find a nice example of this; I'm sure someone's done it, but I've yet to stumble onto it.
If you are looking into the way of programmatic creation JMeter test take a look into the following sources:
JMeter API
How to Write a plugin for JMeter
Five Ways To Launch a JMeter Test without Using the JMeter GUI
If you are looking for an example project you can check out jmeter-from-code solution which demonstrates creating a JMeter Test Plan programmatically, storing it into a .jmx script file, running it and getting the .jtl results file.
Related
For functional automation we use to create a framework which is reusable for automating application. Is there any way to create Performance testing framework in jmeter. So that we can use same framework for Performance testing of different applications.
Please help if any one knows and provide more information regarding it.
You can consider JMeter as a "framework" which already comes with test elements to build requests via different protocols/transports, applying assertions, generating reports, etc.
It is highly unlikely you will be able to re-use existing script for another application as JMeter acts on protocol level therefore there will be different requests for different applications.
There is a mechanism in JMeter allowing to re-use pieces of test plan as modules so you won't have to duplicate your code, check out Test Fragments and Module Controller, however it is more applicable for a single application.
The only "framework-like" approach I can think of is adding your JMeter tests into continuous integration process so you will have a build step which will execute performance tests and publish reports, basically you will be able to re-use the same test setup and reporting routine and the only thing which will change from application to application will be .jmx test script(s). See JMeter Maven Plugin and/or JMeter Ant Task for more details.
You must first ask yourself, how dynamic is my conversation that I am attempting to replicate. If you have a very stable services API where the exposed external interface is static, but the code to handle it on the back end is changing, then you have a good shot at building something which has a long life.
But, if you are like the majority of web sites in the universe then you are dealing with developers who are always changing something, adding a resource, adding of deleting form values (hidden or not), headers, etc.... In this case you should consider that your scripts are perishable, with a limited life, and you will need to rebuild them at some point.
Having noted the limited lifetime of a piece of code to test a piece of code with a limited lifetime, are there some techniques you can use to insulate yourself? Yes. Rule of thumb is the higher up the stack you go to build your test scripts the more insulated you are from changes under the covers ( assuming the layer you build to is stable ). The trade off is with more of the intelligence under the covers of your test interface, the higher the resource cost for any individual virtual user which then dictates more hosts for test execution and more skew from client side code which can distort the view of what is coming from the server. An example, run a selenium script instead of a base jmeter script. A browser is invoked, you have the benefit of all of the local javascript processing to handle the dynamic changes and your script has a longer life.
If there are many jmeter scripts(jmx files) in a stress project for different cases run, how to maintain the common jmeter code which can be shared by each jmx?
For example, many jmx files have same thread group, http sampler, config elements (header manager, Authorization manager etc) ?
Any way to only edit once and apply for all jmx scripts? I couldn't find the related jmeter doc about this? wonder if jmeter jmx file supports any share code dynamic load/management?
Any suggestions are very appreciated!
My expectation is that you're looking for the Module Controller. In conjunction with Test Fragments you will be able to re-use sequences of the Test Elements either in current Test Plan or even in different .jmx scripts.
See Using JMeter Module Controller article for detailed information if needed
I think you mean the Include Controller. That way you can combine different jmx files to be run from one 'master' file. There are some things to keep in mind, but check the manual for that.
I am just wondering is there any way or possible to generate JMeter script on the fly for the existing test automation script.
Basically the idea is to use the same Test automation script let's say Test automation script was created using selenium for the performance testing too using JMeter.
Any ideas or thoughts?
-Raj
Thanks,
Rajani
The solution is to record your Selenium test.
Start JMeter's HTTP(S) Test Script Recorder
Configure your Selenium scripts to use JMeter as a proxy
Start the test - JMeter will be recording.
This way you will get test "skeleton" however you will still need to handle dynamic parameters. To avoid this step you can try out an alternative recording solution, it is capable of exporting JMeter tests in "SmartJMX" mode with automated correlation applied. See How to Convert Selenium Scripts into the JMX article for more details.
The only way I am aware to achieve this is to record the selenium run and then save the jmeter script.
https://guide.blazemeter.com/hc/en-us/articles/206733979-Recording-a-user-session-with-the-proxy
Yes, it is.
You can run the JMeter stuff programmatically using JMeter API.
Using it, you can write your own test harness that creates the test items on the fly, then build the test plan out of them, and run it.
Or loads existing plan "template", access & alter the test elements in it, then, again run it.
Though that is kinda tricky part, so first ask yourself (then share with us here) what exactly do you need it for, and then try to consider the possibility to implement that using JMeter scripting components.
Basically, in your case, you can call the Selenium stuff in the JSR223/Beanshell components through Selenium API.
And moreover, there exist a plugin to do the things with Selenium stuff.
PS Although the very idea of using something all-purpose "to rule 'em all" usually doesn't pay off, 'cause the effort needed to maintain that "universality" often overcome the one smartly made for separate functional/load suites.
I am new with JMeter and I am trying to understand how to work with multiple tests plans.
Is it possible to define multiple tests plans in a single ".jmx" file, each with its own thread groups, etc. ? Or should I save each test plan in a separate ".jmx" file?
What is the correct and common usage?
It depends on your workflow and what you are trying to achieve, the most common use case assumes collaborative work of more than one people on the JMeter test scenario. In this case Test Fragments would be useful.
If you are trying to run several JMeter tests in parallel, the easiest option is using Taurus tool as a wrapper and just pass several .jmx tests to it either in command-line or through YAML configuration file.
I think you are looking for an approach for creating a modular JMeter test scripts.
There are many ways to achieve reusability/modularity in JMeter.
Test Fragment
Module Controller
Parameterized Controller
Include Controller
Check this post for more detailed information.
Keyword driven framework in JMeter.
I am here because I'm asking the same thing than you #SomethingSomething
From my understanding and my point of view, to have multiple tests plans, you must create several .jmx file. For instance, if you need to test different servers or application.
If you need to test multiple scenario in a same application, so combining them into in a single .jmx file should be the better option (by using Fragments or Controllers).
I am working on a project where the core application needs a harness to send messages which will process the message and feed to a portal web application. I am writing the automated testing for the portal application using cucumber/ruby/capybara.
I have never used Jmeter but through a colleague i just understand the basics of the Jmeter GUI tool. I have been asked me to use Jmeter as harness tool so that I can later extend the functionality to do performance testing as well. How can I do this ? How can i use Jmeter in my automated scripts using cucumber/ruby/selenium or capybara to do my testing ?
I dont want to use GUI as the whole test case should be automated end to end, I have to figure out a way to integrate Jmeter functionality to do test data set up and then run my browser test to check whether the data exists.
i hope my question is clear, ask me if you are not. Hoping to get a solution as i dont think it is a uncommon question.
Note: i have seen the ruby-jmeter gem, i think it does partly what i need but it is actually a DSL to use jmeter in ruby.the problem with that is I have to stick the syntax of gem and have to figure all the options in gem. I have also read a blog that this can be done using Jmeter recording proxy and running the browser tests at the proxy which I am not sure how to do that. here is the link where this is mentioned:
https://groups.google.com/forum/#!topic/cukes/4ZGkf3a234Y
As per my understanding of the problem, please go through the below links
for recording the script using Jmeter:
http://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.pdf
for integrating selenium in Jmeter:
There are actually 2 ways of achieving this:
exporting all your selenium scripts as *.jar and copying it to /junit folder under /lib folder of Jmeter.
Use JUnit Sampler to execute your test cases:
http://intensetesting.wordpress.com/2013/09/25/integrating-jmeter-with-selenium-code/
use WebDeriver plugin for Jmeter and write your selenium test cases in Jmeter:
http://jmeter-plugins.org/wiki/WebDriverTutorial/
Also you can run Jmeter via command line.