0Pricing
Load Testing & Performance Benchmarking (JMeter & k6) · Aula

Parametrização com Dados CSV

Utilize a Configuração do Conjunto de Dados CSV para inserir dados de entrada dinâmicos nos seus scripts de teste.

Parametrização com Dados CSV é uma aula grátis de Load Testing & Performance Benchmarking (JMeter & k6) no CoddyKit. Esta é a aula 1 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Load Testing & Performance Benchmarking (JMeter & k6), e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Load Testing & Performance Benchmarking (JMeter & k6) inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

Dynamic Data with CSV

When performance testing, we often need to simulate many users doing similar, but not identical, actions. For example, logging in with different credentials or searching for different items.

This is where parameterization comes in! Instead of hardcoding values, we use variables to inject dynamic data into our tests. This lesson focuses on using CSV files for this purpose in JMeter.

What is Parameterization?

Parameterization is the process of replacing hardcoded values in your test script with variables. These variables then get their values from an external source, like a data file.

  • It makes your tests more realistic by simulating diverse user inputs.
  • It helps prevent caching issues on the server side, as each request can be unique.
  • It allows you to test different scenarios without modifying the test script itself.

Meet CSV Data Set Config

In JMeter, the primary element for parameterization using external files is the CSV Data Set Config. This element reads data from a plain text file, typically with comma-separated values (CSV).

It works by reading a new line of data for each iteration of your test or for each virtual user, making the requests unique.

Preparing Your CSV File

Your CSV file is just a simple text file. Each line represents a set of data for one iteration or one user. Values within a line are separated by a delimiter, usually a comma (`,`).

  • Ensure the file is accessible to JMeter (e.g., in the same directory as your .jmx script).
  • You don't need a header row in the CSV file itself; you'll define variable names in JMeter.

CSV File Example

Here's what a simple CSV file might look like, containing usernames and passwords:

user1,pass1
user2,pass2
user3,pass3

Each line provides a unique pair of username and password that can be used by a different virtual user or in different test iterations.

Adding CSV Data Set Config

To add this element in JMeter:

  1. Right-click on your Test Plan or Thread Group.
  2. Go to Add > Config Element > CSV Data Set Config.

Placing it under the Test Plan makes it available globally. Placing it under a Thread Group limits its scope to that specific group.

Configuring Key Fields

The CSV Data Set Config has several important fields to configure:

  • Filename: Path to your CSV file.
  • Variable Names: Comma-separated list of names for variables (e.g., username,password).
  • Delimiter: Character separating values (default is comma).
  • Recycle on EOF?: If True, JMeter restarts from the beginning of the file when it reaches the end.
  • Stop Thread on EOF?: If True, the thread stops when it runs out of data.
  • Sharing Mode: How data is shared among threads (e.g., All threads, Current thread group).

Using Variables in Requests

Once you've defined your variable names in the CSV Data Set Config (e.g., username and password), you can use them in your JMeter Samplers.

The syntax for referencing a variable is ${variableName}.

For instance, in an HTTP Request, you might use ${username} in the username field and ${password} in the password field.

Example: Login Request

Let's say you're testing a login page that accepts user and pass as parameters. With a CSV file like user1,pass1, you'd configure your HTTP Request as follows:

Method: POST
Path: /login
Parameters:
  user: ${username}
  pass: ${password}

Each time a virtual user makes this request, JMeter will pull the next available username and password from your CSV file.

CSV Configuration Check

You've successfully set up a CSV Data Set Config. Which of the following are crucial settings you must define for it to work correctly?

Recap: Parameterizing with CSV

Great job! You've learned how to parameterize your JMeter tests using the CSV Data Set Config.

  • Parameterization makes tests more realistic.
  • The CSV Data Set Config reads data from a CSV file.
  • You define variable names in the Config element to map to your CSV columns.
  • Use the ${variableName} syntax to reference data in your samplers.
  • Key settings include Filename, Variable Names, Delimiter, Recycle on EOF, Stop Thread on EOF, and Sharing Mode.

Next, we'll explore handling dynamic values directly from server responses!

Perguntas Frequentes

A aula “Parametrização com Dados CSV” é grátis?

Sim — o texto completo de “Parametrização com Dados CSV” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Load Testing & Performance Benchmarking (JMeter & k6), atualize para CoddyKit PRO. O curso de Load Testing & Performance Benchmarking (JMeter & k6) inclui 4 aulas no total.

O que vou aprender em “Parametrização com Dados CSV”?

Utilize a Configuração do Conjunto de Dados CSV para inserir dados de entrada dinâmicos nos seus scripts de teste. Você pratica Load Testing & Performance Benchmarking (JMeter & k6) com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Load Testing & Performance Benchmarking (JMeter & k6)?

Nenhuma experiência prévia é necessária. Load Testing & Performance Benchmarking (JMeter & k6) no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 1 de 4.

Quanto tempo leva a aula “Parametrização com Dados CSV”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Load Testing & Performance Benchmarking (JMeter & k6)?

Sim. Cada aula de Load Testing & Performance Benchmarking (JMeter & k6) inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Parametrização com Dados CSV
  2. Lidando com Valores Dinâmicos (Correlação)
  3. Funções e Variáveis do JMeter
  4. Testes de banco de dados com JDBC
← Voltar para Load Testing & Performance Benchmarking (JMeter & k6)