Execution order and scope of Jmeter components

1. Important components of Jmeter:

1) Configuration element---Config Element:

  Used to initialize default values ​​and variables for use by subsequent samplers. Configuration elements are processed at the initial stage of their scope, configuration elements are only valid for the branch of the test tree they are in, i.e. before any samplers in the same scope.

2) Pre-processor --- Pre Processors:

  The pre-processor will do some special operations before the request from the sampler. If a preprocessor is attached to a sampler, it will only be executed before that sampler is run. Preprocessors are usually used to modify some settings of a sampler before the sampler makes a request, or to update the value of some variables (those variables do not get their values ​​in the server response).

3) Timer---Timer:

  The timer will make each sampler in the scope wait for a fixed period of time before execution. If this delay is not set, JMeter may generate a large number of access requests in a short period of time, causing the server to be flooded with a large number of requests. If multiple timers are added to the thread group, JMeter will add the duration of these timers together to affect the samplers within the scope. A timer can be a child of a sampler or a logic controller, with the intention of only affecting samplers within scope.

4) Sampler---sampler:

  The sampler tells JMeter to send a request to the specified server and wait for the server's request. Samplers are executed in the order they appear in the test tree, and logic controllers can be used to vary the number of iterations of sampler runs.

5) Post processor --- Post Processors:

  Post-processors do special things after a sampler makes a request. If a postprocessor is attached to a sampler, it will only execute after that sampler has run. Post-processors are usually used to process server response data, especially to extract data from server responses.

6) Assertions---Assertions:

  Users can use assertions to check the response content obtained from the server. Assertions can be used to test whether the response returned by the server matches the expectations of the tester

7) Listener---Listener:

  Listeners provide access methods to information collected by JMeter during a test. The "Graphic Results" listener will plot the system response time in a graph. The "View Results Tree" listener will display the details of the sampler's request and response, and can also import test data into a file for subsequent analysis.

8) Logic controller---Controller:

  Logic controllers help users control JMeter's test logic, especially when requests are sent. The logic controller can change the request execution order of its child test elements.

2. Component execution order:

The execution of the elements of the test plan is ordered and executed in the following ways:
1 – Config Element
2 – Pre Processors
3 – Timer 4
– Sampler
5 – Post Processors (Post Processors, only executed when results are available)
6 – Assertions (Assertions, only executed when results are available)
7 – Listener (Listener, executed only when results are available)

3. Component scope:

The component collects and presents the information of each sampler component in its scope. In jmeter, the scope of the component is determined by the parent-child relationship of the component in the tree structure of the test plan. The principle of scope is:

  • Sampler (sampler): The component does not interact with other components, so there is no scope problem.
  • Logic Controller: The component only acts on the samplers and logic controllers in its child nodes.
  • Except for sampler and logic controller components, if the other 6 types of components are child nodes of a sampler, the component will only work on its parent and child nodes.
  • Except for sampler and logic controller components, if its parent node is not sampler, its scope is all other descendant nodes (including child nodes, child nodes of child nodes, etc.) under the parent node of the component.

4. Special instructions:

Config Elemnet --> User Defined Variables: No matter where this component is placed, the variables it defines will be shared by the entire thread.

For example:

In the following example, the test plan is defined as follows:

1. Three samplers are defined: one, Debug Sampler, two

2. A user-defined variable is defined under one: a variable named hello is added here, and the value is world

3. A listener: view the result tree

Purpose: To test whether the variables defined under sampler one can be referenced by sampler two and debug sampler

one:

User Defined Variables:

two:

operation result:

It can be seen from the above that the user variables defined under one can be used normally in debug sampler and two.

Finally: In order to give back to the die-hard fans, I have compiled a complete software testing video learning tutorial for you. If you need it, you can get it for free【保证100%免费】

Software Testing Interview Documentation

We must study to find a high-paying job. The following interview questions are the latest interview materials from first-tier Internet companies such as Ali, Tencent, and Byte, and some Byte bosses have given authoritative answers. Finish this set The interview materials believe that everyone can find a satisfactory job.

Guess you like

Origin blog.csdn.net/IT_LanTian/article/details/131555081
Recommended