How to find all places where variable is used in JMeter scenario? - testing

I use JMeter to record HTTP scenario and do load testing. Now I need to correlate some values using Regular Expression Extractor, for example ${secure_id}, but I don't know how to find all requests where this variable is used. I can substitute this step by step, but it is necessary for me to do it automatically in all places where it is used. Thanks for any answer

You could open your TestPlan.jmx file with text editor notepad++ for example and find+replace all occurrences of ${secure_id} here is an example

Have you seen "Search" option in JMeter's main menu? It's available since JMeter 2.9 if not earlier
As #Boyan suggests JMeter scripts are XML files so you can use your favourite text editor for bulk replacing hardcoded recorded value with the variable
You can use a 3rd-party recorder which has SmartJMX mode. The main feature is automatic correlation of any detected entities. See How to Cut Your JMeter Scripting Time by 80% for details.

Related

JMeter's JSR 233 - Edit option in language is irrelevant

In JMeter JSR 233 element There's an Edit option in language Combo box,
If you leave empty it chooses by default groovy, but if you write engine name it's error prone and irrelevant because according to previous question
drop down is being populated on-the-fly using
ScriptEngineManager.getEngineFactories() method which performs
discovery of available scripting engines in JMeter Classpath.
So if you can choose in drop down only relevant engines why you need to input manually different (not working) engines?
Is it a bug of JMeter? or is there a special reason/usage?
The edit option comes from the fact that a generic combo box component is used for the GUI of this element.
One possible case I see is user having some engine in JMeter install A.
He saves his script.
He opens it with JMeter install B where this engine is not installed, if this option didn't exist, he would lose this setting.

SoapUI - Increase property value for each test case

I want to use a property ('currentId') which has a certain start value. For each test case the value should be increased by 1. I can do that by adding an extra test step in each test case which increases the value but that would be much copy paste. The code for that would be (see reference):
def uniqueUserPortion = testRunner.testCase.testSuite.project.getPropertyValue("currentId")
// convert it to an Integer, and increment
def uniqueUserPortionInc = uniqueUserPortion.toInteger() + 1
// set the property back as string
testRunner.testCase.testSuite.project.setPropertyValue("currentId", uniqueUserPortionInc.toString())
To avoid that copy&paste I've added the code above to the Load Script of the project but it doesn't work:
testSuite.testCases.each {
*code above*
}
What can I do to use the code in one script/call for all test cases?
I could define the property as the start value plus the test case ID but that would be a definition in each test case again since I can not reference the #TestCase#ID in project level/property.
Issue with what your are trying
Load Script of the project is executed once when you import the project into soapui workspace. So, this approach does not work.
As you rightly mentioned, either you need to have it in a separate step of the each test case or you can add the same code as setup script. Yes, it is copy paste only
It is possible to achieve easily using SoapUI NG which pro edition using Event feature.
Then your next question may be : how to do it in Open Source edition of SoapUI.
Here is an soapuiExtensions which I did sometime ago which allows you do the same without having to copy paste for each test case in open source edition.
All you need do is have your groovy script into a specific file called 'TestCaseBeforeRun.groovy'. That means, the script is executed before running each test case.
For more details refer README
This soapuiExtensions library allows users to have some additional functionality in soapUI(free edition) tool, like soapui pro allows to do something before, after doing something.
For eg: User may want to do something before running a test case or after running a test case etc by implementing appropriate groovy script as required. Allow me to add an example here. Usually user may want to add credentials for the request step automatically, see the script samples/scripts/TestSuiteTestStepAdded.groovy
How to use this library:
set SOAPUI_HOME environment variable.
copy lib/SoapUIExtListeners.jar file under $SOAPUI_HOME/bin/ext directory
copy samples/listeners/custom-listeners.xml file under $SOAPUI_HOME/bin/listeners directory
copy samples/scripts directory under $SOAPUI_HOME
And implement appropriate groovy script available under $SOAPUI_HOME/scripts. Refer Mappings file in order to implement respective groovy script.
Note: for windows users, you may need to check %SOAPUI_HOME%\bin\soapui.bat which actually overwrites SOAPUI_HOME, need to fix soapui.bat script if requires.
Uses jdk 7, soapUI 4.5.1, and groovy 1.8.9
Dependency
log4j
UPDATE: this is realted to the note in the above.
As it was mentioned in the note, soapui.bat overrides SOAPUI_HOME environment variable on windows, needs to be tweaked a bit. May be you want to copy that groovy file under %SOAPUI_HOME%\bin\scripts (this is without tweaking soapui.bat)and retry. If your machine is linux then it should work if you copy the groovy file under $SOAPUI_HOME/scripts directory

How to pass random parameters to SilkTest Workbench or Classic Record&Play Scenario

I am new to SilkTest and I don't have any scripting background. What I need to do is to record some test cases and then play them to check my system. After getting used to it, I plan to learn scripting and dive into it, but first things first.
What I need is to pass random generated (or randomly read from a text file or pre-defined) parameters into the recordins so that every time I run the tests, different parameters are used. For example, there is a component in which I write some letters and the component filters the results based on the text. Then, I select one of the results. Now, instead of recording the same letters everytime, how can I use random given parameters?
Thanks
What you are looking for is called Active Data in Silk Test.
It allows enhancing your visual tests with external data, for example from an Excel file.
ActiveData testing enables you to leverage existing data in external files as input for powerful, comprehensive application testing solutions. ActiveData testing enables you to perform multiple transactions against test applications using a different set of data for each transaction without writing complicated code or compromising existing data.
You can find an introduction to Active Data in the online documentation or in the tutorial video.
I have a question, what version of Silk Test are you using, also, what client are you using (Silk Test Workbench, Silk4Net or Silk4J). Each of these clients has the ability to receive parameters from an external source whether it is from a command line or from an external data file.
You indicate that you want random data, do you really mean random data or external data? If it is random data that you want you probably need to use a random number/string generator for the client that you are working with (.Net code for Workbench and Silk4Net and Java code for Silk4J).

Getting jmeter aggregate report information into variables

I am using jmeter to run a series of tests against a web application, mostly web services hosted from Jboss and soon to be Tomcat.
Most of the tests I do run autonomously and I typically write results to a reporting database.
I am trying to find a way to get the information that is displayed in the aggregate report (average, median, max etc..) assigned to variables.
If I can get these values into variables I can then write them to my reporting database and/or perform calculations with them.
The aggregate report is giving me exactly the information that I want, but I don't want to have to manually move the data to a reporting system if I can get away with it.
The easiest way is configure Aggregate Report to write the output to file. After test completion you should be able to load data to database as follows (MS SQL Example)
USE your_schema;
GO
BULK INSERT dbo.your_schema
FROM 'path_to_your_csv_results_file'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO
If you want more flexibility I would suggest using JSR223 Post Processor and Groovy as language to fetch previous sampler details.
There is a pre-defined variable called prev which stands for SampleResult class - see linked JavaDoc on available methods. You can extract required values and store them to JMeter Variables like:
vars.put("StartTime", String.valueOf(prev.getStartTime()));
and then process variables as you wish.
The reason of choosing JSR223 instead of Javascript, BSF, Beanshell, whatever is that JSr223 Sampler in case of Groovy language and compilation caching enabled which gives performance almost equal to native Java code.
JMeter JSR223 recommendation explanation
Comparison Benchmark of JMeter Scripting engines

How to report failed testcase in jira using automation

I am automating a website using selenium webdriver with java, I want to write the result "Pass" or "Fail" in excel sheet. How can i automate the reporting of a failed test case in JIRA by taking the status from excel sheet.
Since you are already writing to an excel file, I understand that you are able to access the contents of the Excel Sheet. If this is not completed yet, you might want to consider using http://poi.apache.org/spreadsheet/index.html for this purpose. Once you have the status of the test cases, you can use the JIRA API to create bugs https://ecosystem.atlassian.net/wiki/display/JRJC/Home. A more specific example of how to do this is mentioned here (https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Create+Issue).
However, since a bug (defect) usually requires more information than a simple PASS / FAIL, I would suggest that you might want to collect more information like the stack trace etc and save it in the excel file (or an XML file) when the test fails.
Which test runner are you using? If it is JUnit / TestNG, I believe a XML file is created by default for a test run, which might have some of this information.
You can use 'Apache POI' to read cells from Excel sheet and 'Jira Client' to update status in Jira.
'Jira Client' is a JIRA REST based client library for Java. You can read more about this here: https://github.com/rcarz/jira-client/blob/master/README.md