Jmeter-----Randomly generated mobile phone number 8 bit and go to heavy, to register mobile phone number of the pressure test

Source: Internet
Author: User
Tags vars

  Requirements: 100,000 times the registration interface of the pressure test, mobile phone number has 126 beginning, the following 8 digits Unlimited

Foreword: In the test, we need to 100,000 times the registration interface, then the mobile phone number is required to complete the inconsistency, or mobile phone number will appear after the mobile phone number has been registered, in order to avoid this situation, we have to fill in the mobile phone number is usually 2 ways, 1, Randomly generated using the random function, 2, manually write 100 numbers in the Excel table, by adding a configuration component CSV Data set config to get. Obviously we will choose the first way of implementation is more convenient. Let's look at how to do this.

The first method:

  Using the function helper directly, use the __random function to generate 8-bit numbers. Possible problems: The number of builds may appear duplicated

  

  

The second method:

  Use timestamp + random number method to avoid duplication and generate 8-digit non-repeating numbers

1, add sampler BeanShell Sampler, and fill in the corresponding operation, the key part

//to avoid duplication of 8 digits after the phone number, use timestamp + random numberPhone=${__time (/100000,)} + ${__random (1,100000,)}; String a= string.valueof (phone);//turn the phone into a string because the phone number requires the type charVars.put ("Phone", a);//set string A to a variableVARs.Get("Phone");//Check the value of the phone in debug sampleLog.info ("8888888888888 hahaha:"+A);//Print view values in LogView

  

 Here, the first half is to take a 10-bit timestamp, followed by a random number of 1 [1,100000], can be repeated, the larger the random range, the last generation of random number is not easy to repeat, when large concurrency, random numbers take quickly, so there is very low likelihood of repetition. So within the scope of the license, try to pull a large random number range.
${__time (,)} is the number that goes to the current millisecond time, 13 digits, and can be used to take a more accurate timestamp

2. Add the set of variables to the request

  

3. Add "View results tree" to view the results of the operation, and add "Bebug Sampler" to view the value of the phone

  

  

  

Jmeter-----Randomly generated mobile phone number 8 bit and go to heavy, to register mobile phone number of the pressure test

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.