public class DslCsvDataSet extends BaseConfigElement
This element reads a CSV file and uses each line to generate JMeter variables to be used in each iteration and thread of the test plan.
Is ideal to be able to easily create test plans that test with a lot of different of potential requests or flows.
By default, it consumes comma separated variables, which names are included in first line of CSV, automatically resets to the beginning of the file when the end is reached and the consumption of the file is shared by all threads and thread groups in the test plan (ie: any iteration on a thread will consume a line from the file, and advance to following line).
Additionally, this element sets by default the "quoted data" flag on JMeter CSV Data Set element.
| Modifier and Type | Class and Description |
|---|---|
static class |
DslCsvDataSet.CodeBuilder |
static class |
DslCsvDataSet.Sharing
Specifies the way the threads in a test plan consume the CSV.
|
guiClass, name| Constructor and Description |
|---|
DslCsvDataSet(String csvFile) |
| Modifier and Type | Method and Description |
|---|---|
protected org.apache.jmeter.testelement.TestElement |
buildTestElement() |
DslCsvDataSet |
delimiter(String delimiter)
Specifies the delimiter used by the file to separate variable values.
|
DslCsvDataSet |
encoding(Charset encoding)
Specifies the file encoding used by the file.
|
DslCsvDataSet |
encoding(String encoding)
Specifies the file encoding used by the file.
|
DslCsvDataSet |
ignoreFirstLine()
Specifies to ignore first line of the CSV.
|
DslCsvDataSet |
ignoreFirstLine(boolean enable)
Same as
ignoreFirstLine() but allowing to enable or disable it. |
DslCsvDataSet |
randomOrder()
Specifies to get file lines in random order instead of sequentially iterating over them.
|
DslCsvDataSet |
randomOrder(boolean enable)
Same as
randomOrder() but allowing to enable or disable it. |
DslCsvDataSet |
sharedIn(DslCsvDataSet.Sharing shareMode)
Allows changing the way CSV file is consumed (shared) by threads.
|
DslCsvDataSet |
stopThreadOnEOF()
Specifies to stop threads when end of given CSV file is reached.
|
DslCsvDataSet |
stopThreadOnEOF(boolean enable)
Same as
stopThreadOnEOF() but allowing to enable or disable it. |
DslCsvDataSet |
variableNames(String... variableNames)
Specifies variable names to be assigned to the parsed values.
|
buildConfiguredTestElement, buildTestElementGui, buildTreeUnder, configureTestElement, durationToSeconds, loadBeanProperties, showAndWaitFrameWith, showFrameWith, showInGui, showTestElementGuiclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbuildTreeUnder, showInGuipublic DslCsvDataSet(String csvFile)
public DslCsvDataSet delimiter(String delimiter)
delimiter - specifies the delimiter. By default, it uses commas (,) as delimiters. If you
need to use tabs, then specify "\\t".public DslCsvDataSet encoding(String encoding)
This method is useful when specifying a dynamic encoding (through JMeter variable or function
reference). Otherwise prefer using encoding(Charset).
encoding - the file encoding of the file. By default, it will use UTF-8 (which differs
from JMeter default, to have more consistent test plan execution). This might
require to be changed but in general is good to have all files in same encoding
(eg: UTF-8).public DslCsvDataSet encoding(Charset encoding)
If you need to specify a dynamic encoding (through JMeter variable or function reference), then
use encoding(String) instead.
encoding - the file encoding of the file. By default, it will use UTF-8 (which differs
from JMeter default, to have more consistent test plan execution). This might
require to be changed but in general is good to have all files in same encoding
(eg: UTF-8).public DslCsvDataSet variableNames(String... variableNames)
If you have a CSV file with existing headers and want to overwrite the name of generated
variables, then use ignoreFirstLine() in conjunction with this method to specify the
new variable names. If you have a CSV file without a headers line, then you will need to use
this method to set proper names for the variables (otherwise first line of data will be used as
headers, which will not be good).
variableNames - names of variables to be extracted from the CSV file.public DslCsvDataSet ignoreFirstLine()
This should only be used in conjunction with variableNames(String...) to overwrite
existing CSV headers names.
public DslCsvDataSet ignoreFirstLine(boolean enable)
ignoreFirstLine() but allowing to enable or disable it.
This is helpful when the resolution is taken at runtime.
enable - specifies to enable or disable the setting. By default, it is set to false.ignoreFirstLine()public DslCsvDataSet stopThreadOnEOF()
This method will automatically internally set JMeter test element property "recycle on EOF", so you don't need to worry about such property.
public DslCsvDataSet stopThreadOnEOF(boolean enable)
stopThreadOnEOF() but allowing to enable or disable it.
This is helpful when the resolution is taken at runtime.
enable - specifies to enable or disable the setting. By default, it is set to false.stopThreadOnEOF()public DslCsvDataSet sharedIn(DslCsvDataSet.Sharing shareMode)
shareMode - specifies the way threads consume information from the CSV file. By default,
all threads share the CSV information, meaning that any thread iteration will
advance the consumption of the file (the file is a singleton). When
randomOrder() is used, THREAD_GROUP shared mode is not supported.DslCsvDataSet.Sharingpublic DslCsvDataSet randomOrder()
When this method is invoked Random CSV Data Set plugin is used.
Warning: Getting lines in random order has a performance penalty.
Warning: When random order is enabled, share mode THREAD_GROUP is not supported.
public DslCsvDataSet randomOrder(boolean enable)
randomOrder() but allowing to enable or disable it.
This is helpful when the resolution is taken at runtime.
enable - specifies to enable or disable the setting. By default, it is set to false.randomOrder()protected org.apache.jmeter.testelement.TestElement buildTestElement()
buildTestElement in class BaseTestElementCopyright © 2023. All rights reserved.