JMeter中的CSV数据配置

JMeter中的CSV数据配置,jmeter,Jmeter,在我的项目中,我需要为每个线程传递1个值,相同的值将被多次使用。 JMeter中有任何选项吗 例如: 我的问题很简单 在线程组中,我将为每个线程分配2个线程和10个循环10个循环 我的要求是,我必须为第一个线程使用第一行数据,相同的数据应该用于10个循环,第二行数据应该用于第二个线程,相同的数据应该用于10个循环 例如: 在csv文件中,我将声明如下: 43 42 45 46 在执行期间,线程1应该始终使用43,即使是10个循环,线程2也应该始终使用42。 如果我在测试计划中只声明了两个线程,

在我的项目中,我需要为每个线程传递1个值,相同的值将被多次使用。 JMeter中有任何选项吗

例如:

我的问题很简单

在线程组中,我将为每个线程分配2个线程和10个循环10个循环

我的要求是,我必须为第一个线程使用第一行数据,相同的数据应该用于10个循环,第二行数据应该用于第二个线程,相同的数据应该用于10个循环

例如: 在csv文件中,我将声明如下:

43
42
45
46
在执行期间,线程1应该始终使用43,即使是10个循环,线程2也应该始终使用42。
如果我在测试计划中只声明了两个线程,那么就永远不应该使用45和46。

下面是如何做到这一点的:

Thread Group (2 threads, iteration : 1)
+-- Debug Sampler with Name : T-${__threadNum}-${__StringFromFile(/Volumes/HD2/csv.csv, line)}
+-- Loop Controller (Iterations : 10)
    +-- Debug Sampler to show you get what you need : T-${__threadNum}-DS-${line}
测试计划:

<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.3" jmeter="2.8-SNAPSHOT.20120923">
  <hashTree>
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
      <stringProp name="TestPlan.comments"></stringProp>
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
        <collectionProp name="Arguments.arguments"/>
      </elementProp>
      <stringProp name="TestPlan.user_define_classpath"></stringProp>
    </TestPlan>
    <hashTree>
      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
        <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
        <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
          <boolProp name="LoopController.continue_forever">false</boolProp>
          <stringProp name="LoopController.loops">1</stringProp>
        </elementProp>
        <stringProp name="ThreadGroup.num_threads">2</stringProp>
        <stringProp name="ThreadGroup.ramp_time">1</stringProp>
        <longProp name="ThreadGroup.start_time">1348513661000</longProp>
        <longProp name="ThreadGroup.end_time">1348513661000</longProp>
        <boolProp name="ThreadGroup.scheduler">false</boolProp>
        <stringProp name="ThreadGroup.duration"></stringProp>
        <stringProp name="ThreadGroup.delay"></stringProp>
      </ThreadGroup>
      <hashTree>
        <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="T-${__threadNum}-${__StringFromFile(/Volumes/HD2/csv.csv, line)}" enabled="true">
          <boolProp name="displayJMeterProperties">false</boolProp>
          <boolProp name="displayJMeterVariables">true</boolProp>
          <boolProp name="displaySystemProperties">false</boolProp>
        </DebugSampler>
        <hashTree/>
        <LoopController guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
          <boolProp name="LoopController.continue_forever">true</boolProp>
          <stringProp name="LoopController.loops">10</stringProp>
        </LoopController>
        <hashTree>
          <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="T-${__threadNum}-DS-${line}" enabled="true">
            <boolProp name="displayJMeterProperties">false</boolProp>
            <boolProp name="displayJMeterVariables">true</boolProp>
            <boolProp name="displaySystemProperties">false</boolProp>
          </DebugSampler>
          <hashTree/>
          <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true">
            <boolProp name="ResultCollector.error_logging">false</boolProp>
            <objProp>
              <name>saveConfig</name>
              <value class="SampleSaveConfiguration">
                <time>true</time>
                <latency>true</latency>
                <timestamp>true</timestamp>
                <success>true</success>
                <label>true</label>
                <code>true</code>
                <message>false</message>
                <threadName>true</threadName>
                <dataType>false</dataType>
                <encoding>false</encoding>
                <assertions>true</assertions>
                <subresults>false</subresults>
                <responseData>false</responseData>
                <samplerData>false</samplerData>
                <xml>false</xml>
                <fieldNames>false</fieldNames>
                <responseHeaders>false</responseHeaders>
                <requestHeaders>false</requestHeaders>
                <responseDataOnError>false</responseDataOnError>
                <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
                <assertionsResultsToSave>0</assertionsResultsToSave>
                <bytes>true</bytes>
                <hostname>true</hostname>
                <threadCounts>true</threadCounts>
                <sampleCount>true</sampleCount>
              </value>
            </objProp>
            <stringProp name="filename"></stringProp>
          </ResultCollector>
          <hashTree/>
        </hashTree>
      </hashTree>
    </hashTree>
  </hashTree>
</jmeterTestPlan>

以下是您如何做到这一点:

Thread Group (2 threads, iteration : 1)
+-- Debug Sampler with Name : T-${__threadNum}-${__StringFromFile(/Volumes/HD2/csv.csv, line)}
+-- Loop Controller (Iterations : 10)
    +-- Debug Sampler to show you get what you need : T-${__threadNum}-DS-${line}
测试计划:

<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.3" jmeter="2.8-SNAPSHOT.20120923">
  <hashTree>
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
      <stringProp name="TestPlan.comments"></stringProp>
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
        <collectionProp name="Arguments.arguments"/>
      </elementProp>
      <stringProp name="TestPlan.user_define_classpath"></stringProp>
    </TestPlan>
    <hashTree>
      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
        <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
        <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
          <boolProp name="LoopController.continue_forever">false</boolProp>
          <stringProp name="LoopController.loops">1</stringProp>
        </elementProp>
        <stringProp name="ThreadGroup.num_threads">2</stringProp>
        <stringProp name="ThreadGroup.ramp_time">1</stringProp>
        <longProp name="ThreadGroup.start_time">1348513661000</longProp>
        <longProp name="ThreadGroup.end_time">1348513661000</longProp>
        <boolProp name="ThreadGroup.scheduler">false</boolProp>
        <stringProp name="ThreadGroup.duration"></stringProp>
        <stringProp name="ThreadGroup.delay"></stringProp>
      </ThreadGroup>
      <hashTree>
        <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="T-${__threadNum}-${__StringFromFile(/Volumes/HD2/csv.csv, line)}" enabled="true">
          <boolProp name="displayJMeterProperties">false</boolProp>
          <boolProp name="displayJMeterVariables">true</boolProp>
          <boolProp name="displaySystemProperties">false</boolProp>
        </DebugSampler>
        <hashTree/>
        <LoopController guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
          <boolProp name="LoopController.continue_forever">true</boolProp>
          <stringProp name="LoopController.loops">10</stringProp>
        </LoopController>
        <hashTree>
          <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="T-${__threadNum}-DS-${line}" enabled="true">
            <boolProp name="displayJMeterProperties">false</boolProp>
            <boolProp name="displayJMeterVariables">true</boolProp>
            <boolProp name="displaySystemProperties">false</boolProp>
          </DebugSampler>
          <hashTree/>
          <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true">
            <boolProp name="ResultCollector.error_logging">false</boolProp>
            <objProp>
              <name>saveConfig</name>
              <value class="SampleSaveConfiguration">
                <time>true</time>
                <latency>true</latency>
                <timestamp>true</timestamp>
                <success>true</success>
                <label>true</label>
                <code>true</code>
                <message>false</message>
                <threadName>true</threadName>
                <dataType>false</dataType>
                <encoding>false</encoding>
                <assertions>true</assertions>
                <subresults>false</subresults>
                <responseData>false</responseData>
                <samplerData>false</samplerData>
                <xml>false</xml>
                <fieldNames>false</fieldNames>
                <responseHeaders>false</responseHeaders>
                <requestHeaders>false</requestHeaders>
                <responseDataOnError>false</responseDataOnError>
                <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
                <assertionsResultsToSave>0</assertionsResultsToSave>
                <bytes>true</bytes>
                <hostname>true</hostname>
                <threadCounts>true</threadCounts>
                <sampleCount>true</sampleCount>
              </value>
            </objProp>
            <stringProp name="filename"></stringProp>
          </ResultCollector>
          <hashTree/>
        </hashTree>
      </hashTree>
    </hashTree>
  </hashTree>
</jmeterTestPlan>
将线程组循环设置为1。 在CSV数据集配置之后,输入一个循环控制器,其中包含案例10中所需的循环数。将共享模式设置为:当前线程组。 将HTTP请求采样器添加为Loop Controller的子级,您就得到了它: 将线程组循环设置为1。 在CSV数据集配置之后,输入一个循环控制器,其中包含案例10中所需的循环数。将共享模式设置为:当前线程组。 将HTTP请求采样器添加为Loop Controller的子级,您就得到了它:
谢谢你的回复。我的问题很简单,在一个线程组中,我将为每个线程分配2个线程和10个循环10个循环我的要求是,我必须为第一个线程使用第一行数据,相同的数据应该用于10个循环,第二个线程使用第二行数据,相同的数据应该用于10个循环。例如:在csv文件中,我将声明如下,43 42 45 46执行时,线程1应始终取43,即使是10个循环,线程2也应始终取42。如果我在测试计划中只声明了两个线程,那么就不应该使用45和46。谢谢你的回复。我的问题很简单,在一个线程组中,我将为每个线程分配2个线程和10个循环10个循环我的要求是,我必须为第一个线程使用第一行数据,相同的数据应该用于10个循环,第二个线程使用第二行数据,相同的数据应该用于10个循环。例如:在csv文件中,我将声明如下,43 42 45 46执行时,线程1应始终取43,即使是10个循环,线程2也应始终取42。如果我在测试计划中只声明了两个线程,那么就永远不应该使用45和46