How to run Robot Framework test cases in JMeter? - jmeter

I had to write my test cases in Robot Framework now I would like to run these test cases in JMeter.
I saw that exist the Jmeter library but this is to execute JMeter tests inside the robot right? I need to do the opposite, run the Robot Framework inside JMeter.
I had a test case like this, how to run in Jmeter? I need to use chrome options....
*** Test Cases ***
${chrome_options} = Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
&{SiteOptions} Create Dictionary last_used=${1470931206} setting=${1}
&{media_stream_mic} Create Dictionary ${url},*=${SiteOptions}
${prefs} Create Dictionary profile.content_settings.exceptions.media_stream_mic=${media_stream_mic} profile.content_settings.exceptions.media_stream_camera=${media_stream_mic}
Call Method ${chrome_options} add_experimental_option prefs ${prefs}
Create WebDriver Chrome chrome_options=${chrome_options}
Go To ${url}
Do some actions....
Someone know if is possible and how to do?

2 Options:
1) Take a look at the nice testframework Taurus with this you can run JMeter and Robot Framework together
2) Create an bat, powershell with the Robot Framework test and call it via the OS Proces Sampler

I would have a look at https://kowalpy.github.io/Robot-Framework-JMeter-Library/ Seems, it can do execution and also report converting to robot framework style/format.

Related

Save File and close Jmeter GUI with command line

I am currently trying to automatically record a JMeter script using Selenium. Therefore i start Jmeter in GUI-Mode through Jenkins (using a batch file) with activated Script Recorder.
Then i run a Selenium-test also through Jenkins and a batch file. The requests that this Selenioum script is doing are successfully being recorded.
The only step that i was not able to figure out yet is to save the recorded JMX-Script and close JMeter.
Is there a way to do this through command line, batch file or other? Doing it manually is not an option since JMeter is running on a remote node through Jenkins.
I was able to close JMeter through a system exit/kill command but this way the jmx-file is not being saved.
I don't think it's possible as of JMeter 5.2.1, you will need to automate JMeter GUI separately using Appium or Sikuli or ldtp
However I believe it will make more sense to reconsider your approach and go for one of the following options:
Replay your Selenium test using JMeter's HTTP(S) Test Script Recorder as the proxy
Use Taurus tool which has Proxy2JMX Converter
If above 2 options for some reason cannot be used in your environment you can automate i.e. JMeter Chrome Extension from Selenium (check out 6 Easy Steps to Testing Your Chrome Extension With Selenium for details) so you will be able to start the recording and export resulting .jmx script directly from your browser without having to communicate with the remote Jenkins/JMeter instances.

how to run tests as per respective suite in 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.

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.

Graph Results via Non GUI mode in JMeter

Is there any possibilities to get my below mentioned Graph Results in JMeter test, which is executed in non GUI mode. I can extract its values using csv, but we need to run the test in non GUI mode to get dashboard results also. Any possibilities for this ?
Given you run your JMeter test in command-line non-GUI mode like:
jmeter -n -t test.jmx -l results.jtl
Once test is finished you should be able to open JMeter GUI, add Graph Results listener, locate results.jtl file using "Browse" button and you will see the chart.
Also there is an option to generate some charts in unattended manner using Command-Line Graph Plotting Tool available via JMeter Plugins project, see Automatically generating nice graphs at end of your Load Test with Apache JMeter and JMeter-Plugins guide for details.
I am trying to write web app based on Django to work with test results, do an online monitoring, etc. (kinda dashboard) for load tests which runned in Jmeter console mode (incl. distributive testing).
Maybe you will want to participate in development or so :):
https://github.com/v0devil/JMeter-Control-Center

Jenkins Integration/Unit Testing

My group will be implementing CI using Jenkins. As such, I want to make sure that any unit and/or integration tests we create integrate easily with Jenkins. We have several different technologies in our stack we are using from C++ code to Oracle PL/SQL packages to Groovy code. We want to develop test drivers (code that wraps and tests these individual code units) that we can integrate with Jenkins so that these tests are automatically run when we perform commits (git) as well as on a nightly basis. My question is, what are the best practices for writing these test drivers so that they will easily integrate with Jenkins when we implement it?
For example, we have have a PL/SQL stored procedure that we want to run tests against as part of our CI testing. I could write a bash shell script that wraps calls to it, I could write a Java program that calls it. Basically I could wrap it in anything. Then the next question is...is there some sort of standard for outputting results so that Jenkins can easily determine if the test passed or failed?
.is there some sort of standard for outputting results so that Jenkins
can easily determine if the test passed or failed?
If your test results are compliant with Junit results,jenkins have junit plugin which give you the better way for tracing test reports (result trend graph) and also test result archiving. converting ant test log to Junit format easier one.
useful links:
http://nose2.readthedocs.org/en/latest/plugins/junitxml.html
https://wiki.jenkins-ci.org/display/JENKINS/JUnit+Plugin
https://wiki.jenkins-ci.org/display/JENKINS/xUnit+Plugin
Jenkins and JUnit
Basically I could wrap it in anything.
I personally prefer to go with Java among your choices.because it give you better Api to create xml files
Use python unittest to wrap any of your tests.
Produce junit xml test results.
One easy way of getting any python unittest to write out junit is from command-line.
yum install pytest
And call your test script like this:
py.test --junitxml result.xml testscript.py
And in jenkins build configuration Post-build actions Add a "Publish JUnit test result report" action with result.xml and any more test result files you produce.
https://docs.python.org/2.7/library/unittest.html
This is just one way of producing junit xml results with python. There are a good few other methods either using unittest module or junitxml or others.

Resources