Jmeter - Execute sampler once per test

2019-08-26 10:03发布

问题:

I have below test plan in my jmeter

|Test Plan
|-Thread Group
|--HTTP Request 1
|--HTTP Request 2
|--HTTP Request 3

In Thread Group I have setted:

  • Number of Threads - 5
  • Ramp-Up Period (in seconds) - 0
  • Loop Count -1

When I run my test Jmeter executes each request five times. I'm looking for way how to execute each sampler only once in whole test run, I know I can achive it by setting Number of Threads to 1, but in that case execution of test will be very slow, so I would like to do this in parallel way.

Any ideas how can I do it ? I know I can't use Only Once Controller because each request is also executed by each thread.

回答1:

You don't need more than 1 thread, you can add JMeter plugin bzm - Parallel Controller

Add it as the parent of the three request and it will execute it in parallel



回答2:

  1. Put your requests under the Switch Controller
  2. Use ${__threadNum} function as the "Switch Value"

Scenario outline:



回答3:

Take a look at the Once Only Controller this controller runs once per testrun. "The Once Only Controller will now execute always during the first iteration of any looping parent controller"



回答4:

Another option is use Throughput Controller as the parent of each request

Throughput Controller allows the user to control how often it is executed.

Choose Total executions with Throughput value 1

Total executions causes the controller to stop executing after a certain number of executions have occurred.

It will execute only once each request as you needed