Introducing Jmeter

A, JMeter execution sequence component

  1. Configuration node
  2. Preprocessor
  3. Timer
  4. Sampler
  5. Post-processor (only in case the outcome of the next available)
  6. Assert (only in the outcome of the next availability)
  7. Listener (only in case the outcome of the next available)

Two, JMeter components Detailed

1, thread

  • Threads: the number of virtual users
  • Ramp-Up Period: virtual users to generate all of the time. Ramp-Up Period set to 0, then all users will immediately generated simultaneously
  • The number of cycles: either N times, or never
  • Scheduler: Set the way the timing of execution may be set at a future time after the start of execution started you can also set the number of seconds. After pressing the Execute button, the scheduler takes effect

2, sampler

  Sampler (the Samples) is a component of a request Jmeter true. Commonly used sampler is an HTTP request the sampler

  • Code: the HTTP sampler, in the variable row you can check the code. If the value of the variable contains a non-Ascii character codes (such as Kanji) comprising Ascii character or special characters (question mark such as spaces or the like), it is necessary to check the code.

3, the controller

  • Logic controller: to perform sequential control of the sampler. In addition to only one controller, the controller can be nested in other types of other logic controllers.
  • Loop controller: the definition of a regular cycle.
    • Name: name of the controller
    • Notes: free to set
    • Prefix input variables: define a set of variables in the "user-defined variables", the loop controller may use to obtain the corresponding value of the variable, then loop controller as a loop condition, may also output variables as parameters of the sampler.
    • Under the loop variable marked the start: Start index for loop
    • At the end of the loop variable label: End index for loop
    • Output Variable Name: variable name cycles generated by the controller
    • Add "_" before number? : Prefix is ​​added to the variable "_" as the delimiter
  • Recording Controller: automatically generated script to record requests in the controller below
  • Transaction controller: Suppose submit a single work requires three steps (step1, step2, step3), each step needs to send a request to the server, in order to obtain a total time of three requests, the controller can use transaction request these three polymerization, the three sub-assemblies as the transaction request controller. Therefore, the controller actual transaction response time is the total polymerized N requests should be combined logically.

4, function

  Function is a programming concept, similar to a box, we enter some values, some of the output value of the box.

  • Random Function: This function we need two input values, a minimum value of a random range, the other one is the maximum random range (e.g. $ {_ Random (1,3)} are generated randomly between 1 to 3 integer; key $ {_ random (1,3)} are randomly generated key1, key2, key3 any of a string)

5, configuration elements

  Configuration elements are used to store configuration information, Jmeter provides a wealth of configuration elements to help us build test scripts. Common elements arranged with a user-defined variable element, HTTP Request Defaults element or the like.

  • CSV data file settings: This component can extract the text line by line from the specified file, the content according to the dismantling of the line delimiter and the content corresponding to the variable name, then these variables can be referenced for the sampler.
    • Name: free to set
    • Notes: casual settings can be empty
    • File Name: Address referenced parameter file
    • File Encoding: Reading parameter file encoding format used, we recommend using UTF-8 format to save the parameter file
    • Variable Name: the name of the parameter defined, separated by commas, and the order of the corresponding parameter in the parameter file
    • Ignore the first line: If the parameter file is the first line of the title is set to True, otherwise it is False
    • Delimiter: delimiter used to separate parameter file (the default is a comma, can also be used to separate tab, if the parameter file separated by tab, this should fill out the "\ t")
    • Whether to allow the quotation marks: If you choose True,
    • Encounters end of file cycle again? :
    • Encounter EOF stop the thread? :
    • Thread shared mode:
  • HTTP header Manager: This component of the role is to set the header http request in Key-Value format, in general we get header http request by way of recording. In addition, each linked to a header request the following information to configure is not conducive to all the requests of our unified thread of control group, we can just hang a header manager in the following thread groups, all http requests in this thread group have the same header a.
  • Random variable: this effect is to generate a character string component + random number format, and stored in a variable, for subsequent use. (E.g., 01-selenium, selenium-01, se001lenium) if there are two simultaneous HTTP requests, which is achieved with two HTTP requests a random variable.

6, listener

  Listeners can be understood as a test report

7, Timer

  The role of the timer is to add "think" time before each operation to the user, allowing users to simulate the behavior is closer to the real user behavior.

  • Fixed Timer: This component of the role is to suspend thread execution, the timer is placed between the two requests, thinking for a fixed period of time.

8, pre-processor

   Pre-processor to do some preparatory work environment or parameters, such as before the operation of the database needs to first establish a database connection, then the pre-processor can perform this function.

9 postprocessor

   After the post-processor general on the sampler, you can help us find the data in the data we need a response from the server.

  • Regular Expression Extractor
    • Name: free to set
    • Notes: free to set
    • Apply to: Applications (four options)
    1. Main Sample and sub-samples: matching range including the current parent sampler and covering the sub-samplers
    2. Main sample only: match the scope of the current sampler father
    3. Sub-samples only: Match only the sub-sampler
    4. JMeter Variable: Support for JMeter variable values ​​match
    • To check the response field: match for different parts of the response data, a total of seven options
    1. Body: the body portion in response to the data, excluding the Header section; protocol returns the Http request body portion is Body
    2. Body (unescaped): Body part for replacing the escape codes
    3. Body as a Document: returns the contents as a document matching
    4. Header: matches only part of the header information
    5. URL: only match the URL link
    6. Response code: matching response code, return protocol such as HTTP success code 200 represents
    7. Response Information: matching response information, such as word processing successfully returns "success" or "OK" word
    • Reference name: access information matches out by this name, reference name} {$ similar access
    • Regular expression: regular expression string extractor uses this information to match
    • Template: Regular expressions can set up multiple templates to match, which can only be in this template, templates, automatic numbering specified use. $ 1 $ refers to the first template, $ 2 $ refers to the second template, and so on, $ 0 $ refers to the full match.
    • Match numbers: often appear when a plurality of matching values ​​match, if the number of matches to 0 to randomly matching value; different templates may match a set value, the match can be taken to determine the set of digital values which one; all take negative values, may be used with for Each Controller to traverse.
    • Default: If no match can be developed to a default value.

10, affirmed

  For assertion verification result is correct, with a predetermined result (the value of the expression, duration and other conditions) and the actual result of the matching, the matching is successful, otherwise fail. Assertion elements are:

  • In response to the assertion
  • XML assertions
  • BeanShell Assertion

 11,Test Fragment

  Test Fragment is an auxiliary component, the script can be used to back up the development process element; under Test Fragment element can be called the controller module, the modular may use it to request (the service package to a method for multiplexing a) The controller module for calling.

 

Guess you like

Origin www.cnblogs.com/xiaopc/p/11096499.html