JMeter – Test Fragment

JMeter - Test Fragment

JMeter Test Fragment element helps to set-up the module-based approach while creating the script of large flow. Let’s try to understand this with an example. Consider you have a transaction flow:

  • Launch Home Page
  • User Sign-up
  • User Verification/Activation
  • User Login
  • Go To Search Page
  • Search a Product
  • View full detail of a product
  • Product  – Add to cart
  • Fill Order form
  • Fill payment details
  • Place Order
  • Update Order
  • Re-submit Order
  • Rate the product

You need to prepare a single JMeter script for above-mentioned flow. You have 1 day and 3 team members. You need to utilize the working bandwidth of all three resources. So how will you manage?

The solution is ‘Test Fragment’ element. By default, JMeter scripts tend to be complex! But there are some great solutions that can help you. JMeter offers test fragmenting to minimize the amount of code in scripts and make it easier to maintain by splitting the flow into small fragments.

Module-based scripting with JMeter Test Fragment:

Test fragment is an effective solution if more than one tester is needed to work on separate modules simultaneously and the modules can be incorporated into one load test. In above example, if you divide the transactional flow into small modules and assign each module among 3 test team members like User Sign-up/Login module, Place Order Module and Update Order Module then you can complete the task in given timelines.

  1. Module-1
    1. Launch Home Page
    2. User Sign-up
    3. User Verification/Activation
    4. User Login
  2. Module-2
    1. Go To Search Page
    2. Search a Product
    3. View full detail of a product
    4. Product  – Add to cart
    5. Fill Order form
    6. Fill payment details
    7. Place Order
  3. Module-3
    1. Update Order
    2. Re-submit Order
    3. Rate the product

After diving the flow into modules, add a test fragment under the test plan by following these steps:

  1. Right-click on ‘Test Plan’
  2. Hover the mouse on ‘Add’
  3. Hover the mouse on ‘Test Fragment’
  4. Click ‘Test Fragment’

Refer to the below video to understand the concept of Test Fragment practically with above example:


Leave a Reply

Your email address will not be published. Required fields are marked *