Automate JMeter Testing with GitHub Actions

HOME

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.example</groupId>
  <artifactId>JMeter_GitHub_Integration</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>JMeter_GitHub_Integration</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.14.0</version>
        <configuration>
          <source>17</source>
          <target>17</target>
        </configuration>
      </plugin>

      <plugin>
        <groupId>com.lazerycode.jmeter</groupId>
        <artifactId>jmeter-maven-plugin</artifactId>
        <version>3.8.0</version>
        <executions>
          <!-- Generate JMeter configuration -->
          <execution>
            <id>configuration</id>
            <goals>
              <goal>configure</goal>
            </goals>
          </execution>
          <!-- Run JMeter tests -->
          <execution>
            <id>jmeter-tests</id>
            <goals>
              <goal>jmeter</goal>
            </goals>
          </execution>
          <!-- Fail build on errors in test -->
          <execution>
            <id>jmeter-check-results</id>
            <goals>
              <goal>results</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <generateReports>true</generateReports>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

mvn clean verify

echo "# JMeter_Github_Integration" >> README.md
git init
git add .
git commit -m "Jmeter Tests"
git branch -M main
git remote add origin https://github.com/vibssingh/JMeter_Github_Integration.git
git push -u origin main

name: JMeter Test Run

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v4
    - name: Set up JDK 17
      uses: actions/setup-java@v4
      with:
        java-version: '17'
        distribution: 'temurin'
    
    - name: Run JMeter tests
      run: mvn clean verify

    - name: JMeter Test Report Generation
      uses: actions/upload-artifact@v4
      if: success() || failure()
      with:
          name: JMeter Report                                             # Name of the folder
          path: target/jmeter/reports/SOAP_Request           # Path to test results  

Below shows all the steps of the workflow.

How to Save JMeter Test Results as CSV and XML Files

Last Updated On

HOME

Saving JMeter test results in multiple formats like CSV and XML is beneficial. It allows for detailed analysis and flexibility in processing. This flexibility is useful for reporting. Here’s a detailed guide on how to save or export the results of your Apache JMeter test script to a CSV or XML file.

The sample request and response used in this tutorial are shown below:

Sample Request

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <NumberToWords xmlns="http://www.dataaccess.com/webservicesserver/">
      <ubiNum>500</ubiNum>
    </NumberToWords>
  </soap:Body>
</soap:Envelope>

Sample Response

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <m:NumberToWordsResponse xmlns:m="http://www.dataaccess.com/webservicesserver/">
      <m:NumberToWordsResult>five hundred </m:NumberToWordsResult>
    </m:NumberToWordsResponse>
  </soap:Body>
</soap:Envelope>

1. Create a Test Plan in JMeter


2. Add Thread Group

  • Select Test Plan on the tree
  • Add Thread Group                                                                                                                               
  • To add Thread Group: Right-click on the “Test Plan” and add a new thread group: Add -> Threads (Users) -> Thread Group

In the Thread Group control panel, enter Thread Properties as follows:

3.  Adding JMeter elements  

The JMeter element used here is HTTP Request Sampler. In the HTTP Request Control Panel, the Path field indicates which URL request you want to send

Add HTTP Request

The below-mentioned are the values used in HTTP Request to perform the test

  • Protocolhttps
  • Method POST
  • Path – /webservicesserver/NumberConversion.wso

Add HTTP Head Manager

SOAP requests require specific content-type headers. The Header Manager lets you add or override HTTP request headers like can add Accept-Encoding, Accept, Cache-Control

To add: Right-click on Thread Group and select: Add -> Config Element -> HTTP Read Manager

The below-mentioned are the values used in Http Request to perform the test
Content-type = text/xml

5. Adding Listeners to save result as CSV File

Listeners – They show the results of the test execution. They can show results in a different format such as a tree, table, graph, or log file

We are adding the Aggregate Report listener.

Aggregate Report

It is almost the same as Summary Report except Aggregate Report gives a few more parameters like, “Median”, “90% Line”, “95% Line” and “99% Line”.

 To add: Right Click on Thread Group > Add > Listener > Aggregate Report

Configure the filename in the Filename field of the Aggregate Report i.e.: [FULLPATH]/results.csv, where [FULLPATH] is the path on the disk to the directory where you want to save the Apache

6. Save the Test Plan

To Save: Click File and Select -> Save Test Plan as ->Give the name of the Test Plan. It will be saved in .jmx format.

7. Run the Test Plan

Click on the Green Triangle as shown at the top to run the test.

8. View the Execution Status

Click on View Result Tree to see the status of Run. A successful request will be of a Green color in the Text Section.

Click on Aggregate Report Result to see the aggregated status of Run.

A file with the Aggregate_Result.csv name will now be created at the path specified.

C:\Users\Vibha\Desktop\Automation\Performance_Testing\AggregateResult_${__time(yyyyMMdd-HHmmss)}.csv
C:\Users\Vibha\Desktop\Automation\Performance_Testing\ggregateResult_${__time(yyyyMMdd-HHmmss)}.xml

${__property(user.dir)}${__BeanShell(File.separator,)}PerformanceResult_${__time(yyyyMMdd-HHmmss)}.csv
${__property(user.dir)}${__BeanShell(File.separator,)}PerformanceResult_${__time(yyyyMMdd-HHmmss)}.xml

We are done! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

Additional Tutorials

How to send GET Requests in JMeter
JMeter Authorization with access token
How to generate JMeter HTML Report? 
Constant Throughput Timer in JMeter
How to generate Random Variables in JMeter

Step-by-Step Guide to Test SOAP Services with JMeter

Last Updated On

HOME


SOAP is a messaging protocol specification for exchanging structured information in the implementation of web services. Its purpose is to induce extensibility, neutrality, and independence. Testing SOAP (Simple Object Access Protocol) services using JMeter requires setting up a test plan. The test plan simulates requests. It also analyzes responses from the SOAP web service.

Here’s a detailed guide to help you test SOAP services using JMeter:

The sample request and response used in this tutorial are shown below:

Sample Request

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <NumberToWords xmlns="http://www.dataaccess.com/webservicesserver/">
      <ubiNum>500</ubiNum>
    </NumberToWords>
  </soap:Body>
</soap:Envelope>

Sample Response

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <m:NumberToWordsResponse xmlns:m="http://www.dataaccess.com/webservicesserver/">
      <m:NumberToWordsResult>five hundred </m:NumberToWordsResult>
    </m:NumberToWordsResponse>
  </soap:Body>
</soap:Envelope>

1. Create a Test Plan in JMeter


2. Add Thread Group

  • Select Test Plan on the tree
  • Add Thread Group                                                                                                                               
  • To add Thread Group: Right-click on the “Test Plan” and add a new thread group: Add -> Threads (Users) -> Thread Group

In the Thread Group control panel, enter Thread Properties as follows:

3.  Adding JMeter elements  

The JMeter element used here is HTTP Request Sampler. In the HTTP Request Control Panel, the Path field indicates which URL request you want to send

Add HTTP Request

The below-mentioned are the values used in HTTP Request to perform the test

  • Protocolhttps
  • Server Name or IPhttp://www.dataaccess.com
  • Method POST
  • Path – /webservicesserver/NumberConversion.wso

Add HTTP Head Manager

SOAP requests require specific content-type headers. The Header Manager lets you add or override HTTP request headers like can add Accept-Encoding, Accept, Cache-Control

To add: Right-click on Thread Group and select: Add -> Config Element -> HTTP Read Manager

The below-mentioned are the values used in Http Request to perform the test
Content-type = text/xml

5. Adding Listeners to Test Plan

Listeners – They show the results of the test execution. They can show results in a different format such as a tree, table, graph, or log file

We are adding the View Result Tree listener & Aggregate Report listener.

View Result Tree

View Result Tree shows the results of the user request in basic HTML format
To add: Right-click on Test Plan, Add -> Listener -> View Result Tree

Aggregate Report

It is almost the same as Summary Report except Aggregate Report gives a few more parameters like, “Median”, “90% Line”, “95% Line” and “99% Line”.

 To add: Right Click on Thread Group > Add > Listener > Aggregate Report

6. Save the Test Plan

To Save: Click File and Select -> Save Test Plan as ->Give the name of the Test Plan. It will be saved in .jmx format.

7. Run the Test Plan

Click on the Green Triangle as shown at the top to run the test.

8. View the Execution Status

Click on View Result Tree to see the status of Run. A successful request will be of a Green colour in the Text Section.

Click on Response data and Response Header to view other information about Response.

Click on Aggregate Report Result to see the aggregated status of Run.

We are done! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

Additional Tutorials

How to send GET Requests in JMeter
JMeter Authorization with access token
How to generate JMeter HTML Report? 
Constant Throughput Timer in JMeter
How to generate Random Variables in JMeter

Database Load Testing with JMeter: A Step-by-Step Guide

HOME

Database load testing simulates multiple users interacting with a database simultaneously, measuring performance, scalability, and reliability under heavy loads. It helps identify bottlenecks, issues, and potential errors that occur with high traffic volumes.

JMeter is a popular open-source tool for load testing databases.

2. Create a Test Plan in JMeter

3. Add Thread Group

  • Select Test Plan on the tree
  • Add Thread Group                                                                                           
    • To add Thread Group: Right click on the “Test Plan” and add a new thread group: Add -> Threads (Users) -> Thread Group

In the Thread Group control panel, enter Thread Properties as follows:

  • Number of Threads: 5 – Number of users connects to the target website
  • Loop Count: 5  – Number of time to execute testing
  • Ramp-Up Period: 1 – It tells JMeter how long to delay before starting the next user.

4. Configuring Database Connection

The JMeter element used here is HTTP Request Sampler. In HTTP Request Control Panel, the Path field indicates which URL request you want to send.

Add JDBC Connection Configuration

To add: Right-click on Thread Group and select: Add –> Config Element –> JDBC Connection Configuration

5. Adding Listeners to Test Plan

Listeners – They shows the results of the test execution. They can show results in a different format such as a tree, table, graph or log file

We are adding  View Result Tree listener & Aggregate Report

View Result Tree

View Result Tree show results of the user request in basic HTML format

To add: Right click Test Plan, Add -> Listener -> View Result Tree

The entire Test Plan will look like as shown below

6. Save the Test Plan

To Save: Click File Select -> Save Test Plan as ->Give name of the Test Plan. It will be save as .jmx format.

Sample .jmx File

7. Run the Test Plan

Click on Green Triangle as shown below to run the test.

8. View the Execution Status

Click on View Result Tree to see the status of Run. Successful request will be of Green color in the Text Section. The View Results Tree listener breaks down each request and response in detail, including:

The response body as well as response headers can be seen in the listener.

That’s it! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

JMeter Multiple Choice Answers – MCQ1

HOME

JMeter Multiple Choice Questions – MCQ1

























JMeter Multiple Choice Questions – MCQ1

HOME

Answer


Answer


Answer



Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer





====================================================================

JMeter Tutorials

HOME

Chapter 1 How to send GET Requests in JMeter
Chapter 2 How to send POST requests in JMeter
Chapter 3 JMeter Authorization with access token
Chapter 4 Step-by-Step Guide to Test SOAP Services with JMeter – NEW

How to generate Random Variables in JMeter

Last Updated On

HOME

This tutorial tells how random variable can generate and pass as a part of a request in JMeter. Suppose, in the load test, there is a requirement to pass random or different values to a specific parameter in the requests, how this can be achieved. One of the ways is to pass different values from a .csv file that contain different values and use them in the requests. The second way is to add Random Variable in JMeter, which generates random values at every run for requests. 

Table of Contents

What is Random Variable in JMeter?

The random variable config element is used to generate random numeric values within a range of specified minimum and maximum values.

 

Variable name: The name we are going to use to invoke the variable. “ReqCacheKey” in this example.

Output Format: The format for the variable. You can set the desired length of the number. I have set 0000000000 in order to work with a five-digit number. You can also use USER_000.

Minimum and Maximum: The range we want to set for the variable.

Seed: The seed for the random number generator. A seed is the first input that the number generation function receives to start the random generation. Here, it is ${__time()}. This will randomly generate the value like 1256078934, 9863457201

Per Thread: Is important to consider this option. If you set it as True, the threads will share the value. This means that there will be threads with the same value. If you require the variable to be different each time, this could cause problems for us. If you want to always generate a different value, you have to set it as False.

Create a Test Plan in JMeter

Add Thread Group

Select Test Plan on the tree

Add Thread Group                     

To add Thread Group: Right click on the “Test Plan” and add a new thread group: Add -> Threads (Users) -> Thread Group

In the Thread Group control panel, enter Thread Properties as follows: 

Number of Threads: 1 – Number of users connects to the target website
Loop Count: Infinite  – Number of times to execute testing
Ramp-Up Period:
Duration: 5 sec

Adding HTTP Request   

The JMeter element used here is HTTP Request Sampler. In HTTP Request Control Panel, the Path field indicates which URL request you want to send

Add HTTP Request Sampler

To add: Right-click on Thread Group and select: Add -> Sampler -> HTTP Request

Below-mentioned are the values used in HTTP Request to perform the test.

Name – HTTP Request 
Server Name or IP – localhost
Port – 8010
Method – POST
Path – /demo/helloworld

Add a Random Variable

 To add: Right-click on Thread Group and select: Add -> Config Element-> Random Variable.

The sample Request is shown below. cacheKey variable is parameterized. ReqCacheKey in Random Variable will generate the random values, which will be passed to the parameter cacheKey present in the request body

Seed is ${__time()}. This generates the value randomly, like 1256078934, 9863457201. If I keep Seed blank, then when the tests run multiple times, it has the same set of random values (repetitive values), we don’t want the same repetitive values, so seed is not blank

Adding Listeners to the Test Plan

Listeners

They show the results of the test execution. They can show results in a different format such as a tree, table, graph, or log file

We are adding the View Result Tree listener

View Result Tree – View Result Tree shows the results of the user request in basic HTML format

To add: Right click Test Plan, Add -> Listener -> View Result Tree

Save the Test Plan

To Save: Click File Select -> Save Test Plan as ->Give the name of the Test Plan. It will be saved as .jmx format

Run the Test Plan

Click on Green Triangle as shown at the top to run the test

View the Execution Status

Click on View Result Tree to see the status of Run. A successful request will be of a Green colour in the Text Section

In the below image, we can see that the cacheKey value is 1917449705 which is generated by Random Variable

Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!! Cheers!!

Additional Tutorials

 How to send POST requests in JMeter
JMeter Authorization with access token
 How to run JMeter tests from the command line 
Constant Throughput Timer in JMeter
How to create Web Test Plan for JMeter? 
How to run JMeter tests from the command line

How to send POST requests in JMeter

Last Updated On

HOME


We can perform GET as well as POST operations in JMeter. In this tutorial, we will only explain how we send POST HTTP requests in JMeter. In the previous tutorial, I explained how we can send GET request in JMeter.

Table of Contents

  1. Create a Test Plan in JMeter
    1. Add Thread Group
    2. Adding JMeter elements  
    3. Adding Listeners to Test Plan
    4. Save the Test Plan
    5. Run the Test Plan
    6. View the Execution Status

The sample request and response used in this tutorial are shown below:

Sample Request

{
    "name": "Test",
    "job": "JMeter"
}

Sample Response

{
  "name":"Test",
  "job":"JMeter",
  "id":"955",
  "createdAt":"2023-07-03T15:46:18.038Z"
}

Create a Test Plan in JMeter


Step 1 –  Add Thread Group

  • Select Test Plan on the tree
  • Add Thread Group                                                                                                                               To add Thread Group: Right-click on the “Test Plan” and add a new thread group: Add -> Threads (Users) -> Thread Group

In the Thread Group control panel, enter Thread Properties as follows: We will take an example of row no 5

Number of Threads: 5 – Number of users connects to the target website
Loop Count: 5  – Number of times to execute testing
Ramp-Up Period: 5 – It tells JMeter how long to delay before starting the next user. For example, if we have 5 users and a 5 -second Ramp-Up period, then the delay between starting users would be 1 second (5 seconds /5 users).

Step 2 –  Adding JMeter elements  

The JMeter element used here is HTTP Request Sampler. In the HTTP Request Control Panel, the Path field indicates which URL request you want to send


2.1 Add HTTP Request Sampler
To add: Right-click on Thread Group and select: Add -> Sampler -> HTTP Request

The below-mentioned are the values used in HTTP Request to perform the test

  • Name – HTTP POST Request Demo
  • Server Name or IP – reqres.in
  • Port
  • Method – POST
  • Path – /api/users

2.2 Add HTTP Head Manager

The Header Manager lets you add or override HTTP request headers like can add Accept-Encoding, Accept, Cache-Control

To add: Right-click on Thread Group and select: Add -> Config Element -> HTTP Read Manager

The below-mentioned are the values used in Http Request to perform the test
Content-type = application/json
accept – application/json

Step 3 – Adding Listeners to Test Plan

Listeners – They show the results of the test execution. They can show results in a different format such as a tree, table, graph, or log file
We are adding the View Result Tree listener

View Result Tree – View Result Tree shows the results of the user request in basic HTML format
To add: Right-click on Test Plan, Add -> Listener -> View Result Tree

Aggregate Report

It is almost the same as Summary Report except Aggregate Report gives a few more parameters like, “Median”, “90% Line”, “95% Line” and “99% Line”.

 To add: Right Click on Thread Group > Add > Listener > Aggregate Report

Step 4 – Save the Test Plan

To Save: Click File Select -> Save Test Plan as ->Give the name of the Test Plan. It will be saved in .jmx format.

Step 5  – Run the Test Plan

Click on the Green Triangle as shown at the top to run the test.

Step 6 – View the Execution Status

Click on View Result Tree to see the status of Run. A successful request will be of a Green colour in the Text Section.

Click on Response data and Response Header to view other information about Response.

Click on Aggregate Report Result to see the aggregated status of Run.

We are done! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

Additional Tutorials

How to send GET Requests in JMeter
JMeter Authorization with access token
How to generate JMeter HTML Report? 
Constant Throughput Timer in JMeter
How to generate Random Variables in JMeter

How to use Response Assertion in JMeter

HOME

What is Response Assertion?

The response assertion control panel lets you add pattern strings to be compared against various fields of the request or response. The pattern strings are:

Contains, Matches: Perl5-style regular expressions

Equals, Substring: plain text, case-sensitive.

You can also choose whether the strings will be expected to match the entire response, or if the response is only expected to contain the pattern. You can attach multiple assertions to any controller for additional flexibility.

What is Assertion Results

The Assertion Results visualizer shows the Label of each sample taken. It also reports failures of any Assertions that are part of the test plan.

Note – Assertion Results MUST NOT BE USED during load test as it consumes a lot of resources (memory and CPU). Use it only for either functional testing or during Test Plan debugging and Validation.

Create a Test Plan in JMeter

Step 1 –  Add Thread Group

Select Test Plan on the tree

Add Thread Group                           

To add Thread Group: Right click on the “Test Plan” and add a new thread group: Add -> Threads (Users) -> Thread Group

In the Thread Group control panel, enter Thread Properties as follows: 

Number of Threads: 1 – Number of users connects to the target website
Loop Count: 1 – Number of time to execute testing
Ramp-Up Period:

Step 2 –  Adding JMeter elements  

The JMeter element used here is HTTP Request Sampler. In HTTP Request Control Panel, the Path field indicates which URL request you want to send

Add HTTP Request Sampler

To add: Right-click on Thread Group and select: Add -> Sampler -> HTTP Request

Below mentioned are the values used in HTTP Request to perform the test

Name – HTTP Request 
Server Name or IP – localhost
Port – 8000
Method – GET
Path – /example

Step 3 – Add Assertions

Add Response Assertion

The response assertion control panel lets you add pattern strings to be compared against various fields of the request or response.

 To add: Right-click on HTTP Request and select: Add -> Assertions-> Response Assertions

Here, I have selected below options:-

Apply to : Main Sample only
Field to Test: Text Response
Pattern Matching Rules: Contains
Pattern To Test: Linda

Step 4 – Add Listeners

Add Assertion Results

The Assertion Results visualizer shows the Label of each sample taken. It also reports failures of any Assertions that are part of the test plan.

To add: Right-click on Thread Group and select: Add -> Listener-> Assertion Results

View Result Tree 

View Result Tree show results of the user request in basic HTML format

To add: Right click Test Plan, Add -> Listener -> View Result Tree

Step 5 – Save the Test Plan

To Save: Click File Select -> Save Test Plan as ->Give name of the Test Plan. It will be saved as .jmx format

Step 6  – Run the Test Plan

Click on Green Triangle as shown at the top to run the test

Step 7 – View the Execution Status in Assertion Results

Click on Assertion Results to see the status of Run. Successful request will like shown below.

If the test fails, we will see message mentioning the error in the Assertion Results 

Step 8  – View the Execution Status in View Result Tree

 Click on View Result Tree to see the status of Run. Successful request will like shown below.

View Result Tree with failed request looks like below.

That’s it! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!