This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Running Jmeter test script (.jmx)
Usually, Jmeter tests are executed from the Jmeter tool GUI. If you want to execute a test script without using the Jmeter GUI, you can use the Jmeter command-line arguments option or find a maven plugin to do it.
Test Automation Framework also provides the ability to execute the Jmeter test without using the GUI. This helps you to run a Jmeter script programmatically. Test Automation Framework looks after the underlying Jmeter test execution. It uses the Jmeter command-line options to execute the test and initializes a jmeter in the target directory. No Jmeter installation is required to execute the test.
A Jmeter script which tests the service list page of the WSO2 ESB contains the following requests:
- Go to the login page
- Authenticate using the username and password
- Go to the List Services page
- Sign out
Create a maven project with the following dependency:
<dependencies> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.1.1</version> </dependency> <dependency> <groupId>org.wso2.carbon.automation</groupId> <artifactId>org.wso2.carbon.automation.extensions</artifactId> <version>4.3.0</version> </dependency> </dependencies>
Create a testing test class to execute the test. You need to point out your .jmx file path.
package com.test; import org.testng.annotations.Test; import org.wso2.automation.tools.jmeter.JMeterTest; import org.wso2.automation.tools.jmeter.JMeterTestManager; import java.io.File; public class JMeterTestToListServicesTestCase { @Test() public void listServices() throws Exception { JMeterTest script = new JMeterTest( new File("/home/nuwanw/projects/JmeterIntegrationWithFramework" + "/src/test/resource/jmeter/ESB-list-service.jmx")); JMeterTestManager manager = new JMeterTestManager(); manager.runTest(script); } }
You have now added a test to execute the jmeter test.
Add the following surefire configuration in the pom file to run the test while building the project:
<build> <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.12.3</version> <inherited>false</inherited> <configuration> <argLine>-Xms512m -Xmx1024m -XX:MaxPermSize=128m</argLine> <testFailureIgnore>true</testFailureIgnore> <disableXmlReport>false</disableXmlReport> <parallel>false</parallel> <includes> <include>**/*TestCase.java</include> </includes> </configuration> </plugin> </plugins> </build>
If there are no failures, you can see the test result after building the project:
Results : Â
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
The Jmeter test executor generates a separate log file and report file (.jtl) for each and every test script executed. If you need any further result, go to the target directory. Under the Jmeter directory, you can find log and report directories with  .log and .jtl files. The files are generated using your test script name + timeStamp.Â
Now you can execute the Jmeter test which ensures functionality of a product with proper assertions on product integration test while building the product.