DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • Solid Testing Strategies for Salesforce Releases
  • Apex Testing: Tips for Writing Robust Salesforce Test Methods
  • A General Overview of TCPCopy Architecture
  • Modes and Modality in Performance Testing

Trending

  • The Future of Java and AI: Coding in 2025
  • Memory Leak Due to Time-Taking finalize() Method
  • Integrating Model Context Protocol (MCP) With Microsoft Copilot Studio AI Agents
  • Metrics at a Glance for Production Clusters
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Testing, Tools, and Frameworks
  4. How to Use Counter in JMeter

How to Use Counter in JMeter

This article talks about using the Counter element in a performance test script.

By 
Maharshi Shah user avatar
Maharshi Shah
·
Sep. 23, 16 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
39.6K Views

Join the DZone community and get the full member experience.

Join For Free

From sending an email to load testing database, JMeter allows us to create some really sophisticated load testing scenarios. It provides a range of different elements to accomplish our performance testing goals. Counter is one such JMeter element which can prove immensely useful for testers. In this article, we will see how we can use JMeter Counter in our performance test script.

For easier understanding here, we will take an example of test data generation using JMeter. In that, we will register multiple users by incrementing a username (Eg. user+1, user+2, user+3 and so on). This is a very simple example of test data creation which testers often have to carry out. And it can be automated using JMeter Counter. So, without wasting any more time, let’s see how we can do this.

Using JMeter Counter:

  • The screenshot below shows parameters for an HTTP request. Since we will be sending our request in JSON format, we have selected Body Data option here.
  • HTTP RequestHTTP Request
  • We will change ‘username’ value in the above request to ‘user+1’, ‘user+2’ etc for multiple user creation. This is where JMeter Counter comes into the picture. It allows us to increment a value by some number. To add JMeter Counter in the script, right click Thread Group and select Add–>Config Element–>Counter option.
  • The screenshot below shows options present in Counter element. Since we are starting from value 1 and incrementing it by 1, we have set Start and Increment values by 1 respectively. Reference Name value is set to ‘userCount’ which we will use in our JSON request.
  • JMeter Counter OptionsJMeter Counter Options
  • Since we have our counter setup now, we just need to update our JSON request with a counter reference name (userCount in our case). The screenshot below shows how we can do it.
  • Updated HTTP RequestUpdated HTTP Request
  • Now that we have our setup ready, we can run our script for multiple users and get our users created with sequential numbers.
  • While this example of JMeter Counter shows test data creation, it can come in handy for other testing activities also. We encourage you to try it out in your project and share your feedback in comments.

    Test data

    Published at DZone with permission of Maharshi Shah. See the original article here.

    Opinions expressed by DZone contributors are their own.

    Related

    • Solid Testing Strategies for Salesforce Releases
    • Apex Testing: Tips for Writing Robust Salesforce Test Methods
    • A General Overview of TCPCopy Architecture
    • Modes and Modality in Performance Testing

    Partner Resources

    ×

    Comments
    Oops! Something Went Wrong

    The likes didn't load as expected. Please refresh the page and try again.

    ABOUT US

    • About DZone
    • Support and feedback
    • Community research
    • Sitemap

    ADVERTISE

    • Advertise with DZone

    CONTRIBUTE ON DZONE

    • Article Submission Guidelines
    • Become a Contributor
    • Core Program
    • Visit the Writers' Zone

    LEGAL

    • Terms of Service
    • Privacy Policy

    CONTACT US

    • 3343 Perimeter Hill Drive
    • Suite 100
    • Nashville, TN 37211
    • support@dzone.com

    Let's be friends:

    Likes
    There are no likes...yet! 👀
    Be the first to like this post!
    It looks like you're not logged in.
    Sign in to see who liked this post!