how to run tests as per respective suite in jmeter - jmeter

I have created some testcases in Jmeter.
Now I want to run them separately example smoke testcases only.
Is there any way in Jmeter so I can run my JMeter project for a particular group/collection/suite only.
Is Jmeter provide any annotation or containers mechanism from where I can achieve same.
I have written my cases in Jmeter in below assertions
JSR223 Assertion
Response Code
Response Text
Any workaround will be helpful and appreciated in advance

The right way to module your JMeter scripts is to save small script in different JMXs and combined them by calling each or inside a bigger JMX file which uses Include Controller to execute different JMX files
The include controller is designed to use an external JMX file. To use it, create a Test Fragment underneath the Test Plan and add any desired samplers, controllers etc. below it. Then save the Test Plan. The file is now ready to be included as part of other Test Plans.
Inside JMX you can also use Module Controller to reduce code duplication
The Module Controller provides a mechanism for substituting test plan fragments into the current test plan at run-time.
If you want to execute specific test I suggest send specific properties and check the property inside an If Controller .
for example call with property jmeter -JexcludeTest1=true ...
And add an If Controller before test 1:
"${__P(excludeTest1)}" == "true"

The easiest way is using Taurus tool as a wrapper for your JMeter script, it has Modifications for Existing Scripts feature where you can define which test elements you want to enable/disable during test execution.
scenarios:
modification_example:
script: tests/jmx/dummy.jmx
modifications:
disable: # Names of the tree elements to disable
- Thread Group 1
enable: # Names of the tree elements to enable
- Thread Group 2
See Navigating your First Steps Using Taurus to get started.
Another option is putting requests you would like to enable/disable on demand under If Controllers so you could set "run/not run" condition dynamically.

Related

In Taurus, How to set "Clear cookies each iteration" to true?

I am trying to clear cookies after each iteration in Taurus yaml.
I tried the solution from below thread but it didn't work:
[Google Group] https://groups.google.com/g/codename-taurus/c/wa4xIbxkUYI?pli=1
Above thread says:
For reference I did it like this:
modifications:
set-prop:
"Cookies>CookieManager.clearEachIteration": "true"
I have tried the same but didn't work.
Using JMeter I can clear the cookies but need the same behavior for Taurus. Any help.
What do you mean "for Taurus"? Taurus just provides YAML configuration of some of JMeter test elements. The "solution" you're referring is for running existing .jmx script using Taurus
Taurus doesn't support 100% of JMeter functionality when it comes to building test plan from config, refer the documentation to see what is supported.
If you want to use some JMeter functionality which is not supported by Taurus the options are in:
Reach out to Taurus developers via the forum you're referencing and ask them to implement the functionality you need
Implement it yourself, Taurus is an open source project
Switch to the existing .jmx script execution
Switch to JMeter and stop using Taurus as a wrapper
Use JR223 Test Elements to perform the removing of cookies, i.e. you could add a JSR223 PreProcessor to the first sampler in the Thread Group and call sampler.getCookieManager().clear() function there where sampler stands for HTTPSamplerBase

JMeter - Execute specific components only on GUI and not CLI

I add several components for debugging as Debug Sampler, View Results Tree and JSR223 Sampler that are useful in GUI mode, but I want it to be ignored when running load test,
Is there such option of executing Sampler/Listener only in GUI mode and not in command line/"load" mode?
I am not sure that this is the exact answer you are looking for but still let me try. We know that JMeter script is nothing but xml in disguise and structure look like this.
So for every Jmeter component, there is enable property which needs to be true so that it will get executed as part of JMeter Test plan. Now if we can change this some properties which can be passed as parameter then we can make them disable at the run time.
Change in jmx will be reflected like this...
If you run this script in Non GUI mode with additional property passed as parameter, we essentially achieve what we want.
jmeter -n -t .\ExcludeJMeterComponent.jmx -l result.CSV -e -o "Output" -DenabledDebugComponents=false
Issue with this approach is, if you load this script again in JMeter, these values, manually edited jmx going to go away/get override with your next save but if you are using any version control system to keep track of your jmx script [which you must be doing] it will be very easy to add this changes in the script again in no time.
I will post this with more details once my blog is set up.
Found a workaround, to send in CLI JMeter property as -JignoreFirstSampler
Add If Controller as a parent of samplers to exclude checking if property is defined
${__isPropDefined(ignoreFirstSampler)}
The __isPropDefined function returns true if property exists or false if not.

How to show the results in real time in result tree controler when running jmx in command line

im running 3 JMX's from main JMX , i run them using JSR223 Sampler
which executing them VIA beanshell script . they are running one by one.
my question can i get the results of the running JMX in the "View Results Tree"?
in real time while the JMX executing from command line?
Running external JMeter scripts from "main" script using JSR223 Test elements is not the best option, consider using Include Controller or Module Controller instead.
Beanshell scripting is not the best option, consider using Groovy instead
Running JMeter tests in GUI mode is not the best option, consider executing your test in command-line non-GUI mode instead.
Using View Results Tree listener in particular (and listeners in general) is not the best option as they don't add any value but consume valuable resources. If you need real-time results consider connecting JMeter with Grafana.

Is it possible to reuse created jmeter test plan for another test environment?

I have recorded a jmeter script for wiki page. That record was done in one of our test environment. That script is working fine and now i want to perform same load test for another test environment(Both environments are same, only urls are different).Is it possible to reuse?How can i do it?
I have added HTTP Request default element at the begging of test plan creation. Now recorded script consist of many HTTP Request element. Each request element contains Server IP of test instance.
Extract IPs and other env-specific data to .properties file:
http://jmeter.apache.org/usermanual/get-started.html#options
Read them in your JMeter with JMeter built-in function ${__P(someName)} as you see fit
Run your generic JMeter test with env-specific config data in .properties file
Yes. It is possible to run the same test in multiple environments. It all depends on how you design your test plan.
This site has exact details you are looking for.
http://www.testautomationguru.com/jmeter-manage-test-plan/

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