Skip to content
Learn with RV – Tech Blog
Learn with RV – Tech Blog

#testautomation #qa #programming #linux #devops

  • Home
  • Who am I?
  • 1-on-1 Mentoring
  • 18 Testimonials
  • YouTube
  • LinkedIn
  • Contact
Learn with RV – Tech Blog

#testautomation #qa #programming #linux #devops

k6-test-data-logo
April 26, 2024October 2, 2024

4 ways to handle Test Data in k6 – Load Testing

Test data is the information designed to be used by test script during execution. Using different values for certain parameters will make the test more realistic.

Common use cases for test data might be usernames and passwords, emails, addresses, names, personal information, prodct names and so on.

In this article we will explore 4 ways of handling this subject. It worths mentioning that the SharedArray approach will be the most efficient method.

1) Arrays - simplest way to add test data

2) CSV file

In this approach we are going to keep the data sets (pairs of usernames+passwords) into a CSV file, import it in our k6 script then use a random variable that randomly picks data

k6-test-data-csv
k6-script-test-data-csv

3) JSON file

In this approach we are going to keep the data sets (pairs of usernames+passwords) into a JSON file, import it in our k6 script then use a random variable that randomly picks data

k6-test-data-json-script

4) SharedArray - the most efficient approach

The shared array approach must be combined with any of the previous approaches and it is the most efficient way to add data within a k6 test because it handles the high resource utilization most efficiently.

The reason is that in the previous approaches when a file is used in a test, multiple copies of the files are created and sent to the load generator; when the file is large it can have an impact on the resources. Hence, to prevent this, the SharedArray approach should be the go-to option.

In the following example, I will be using SharedArray combined with the JSON approach.

Source code HERE

 

Enjoyed this article? Make sure to subscribe to my YouTube Channel for more Test Automation tutorials, and follow me on LinkedIn and Twitter for regular insights.
Looking to improve your test automation skills?
I’ve created a personalized 1-on-1 Mentoring program refined to boost YOUR skills. Reach out at iamrv@razvanvancea.ro for more details and together will create a learning path adapted to your current skills and goals that you are aiming for, in a timely-efficient manner🚀

Post Views: 465

Related

Share this article:
QA

Post navigation

Previous post
Next post

Recent Posts

  • Using cross-env in Your Node.js Projects: A Practical Guide
  • How to copy-paste text from clipboard using TestCafe
  • How to copy-paste text from clipboard using Cypress
  • How to repeat any CLI Command for X times using NPM repeat-cli-command
  • k9s: A Guide to Master Kubernetes Clusters from your Terminal

Recent Comments

  1. Paul on Web Accessibility: A step-by-step guide to Testing with pa11y
  2. Automated Tests for website Accessibility with Axe and TestCafe - Learn with RV - Tech Blog on How to generate E2E TestCafe Framework in seconds
  3. RV on Exploring Faker.js: A Powerful Tool for Generating Realistic Random Test Data
  4. Adrian Maciuc on Exploring Faker.js: A Powerful Tool for Generating Realistic Random Test Data
  5. Nick on Cypress vs Playwright vs Testcafe – which framework is faster?

Archives

  • June 2025
  • March 2025
  • February 2025
  • January 2025
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023

Categories

  • Linux
  • Programming
  • QA
  • Tools
  • Uncategorized
©2025 Learn with RV – Tech Blog | WordPress Theme by SuperbThemes