This article has participated in the “Digitalstar Project” and won a creative gift package to challenge the creative incentive money.

preface

I will not compare the performance testing tools used or heard of by the author here, because baidu can give you a general idea.

This article is mainly about JMeter, how to develop scripts, develop scripts quickly, solve problems related to scripts, and summarize their experience in using jMeter.

The author is familiar with Jmeter calculations, although Loadrunner is also familiar with them, but is currently known to be running neck and neck with it from recruitment JD descriptions.

I. Introduction to JMeter

I already pasted a large paragraph of text, but I deleted it again, why? Because there’s a little bit of padding, and it’s known,

For detailed introduction, the author recommends the official website of JMeter. For details, please refer to the official website. There are not only introduction and installation steps, but also operation manual of various components, as well as more advanced gameplay. Welcome to ask if you don’t understand!!

1.1. The installation process is omitted

JDK and JMeter installation packages need to be downloaded. The path environment variable < java-version > is automatically added to the next step in jdk1.8.

If not, manually add the path environment variable. Jmeter does not need to be installed. Decompress jMeter.

Start jMeter and the interface will look like this:

1.2. How to use it

Right-click the test plan and create a thread group –> Add sampler –> Add back processor –> Add assertion –> Add Listener –> OK done!

Note that JMeter components are executed sequentially, not from top to bottom. This article does not cover use!

Second, recording script

When it comes to recording scripts, who’s better than Loadrunner? But Jmeter is not alone today.

2.1 Badboy+ Jmeter recording

This combination is very popular for beginners, but the author tells you that it and the browser will have some compatibility problems, will make you record failure and have to give up the choice of other way to develop scripts, in the end will be more than worth the loss, suggested to give up!!

2.2, HTTP Proxy Server [(WAS: HTTP Proxy Server)]

The name is interesting. It used to be called the HTTP proxy server, which is set up to record requests to thread groups, and is now called the test script recorder.

Step 1: Right-click to add a thread group (to place the recorded script)Step 2: Right-click to add non-test components: HTTP(S) Test Script Recorder Port Proxy port, you need to set HTTPS domains across the browser to be the same proxy port, HTTPS domains is the address you want to access Step 3: Set up the local proxy server, set the browser advanced Settings, and keep the port consistent with the JMeter proxy port. Step 4: Click Start, a popup window will appear, click OK, and a certificate will be generated in jmeter/bin directory for recording HTTPS. If you want to record HTTPS scripts, you need to add the JMeter trust certificate. Click Install Step 5: Click Start, make sure the popup window “Play every time”, the new version can add transactions, that is, each time different business scenarios can name transactions

You can see the different transaction name each time: Index \login\ View \replay\topic

Step 6: You can exit recording, click the green triangle, start playing back the script (after this step, one needs to analyze the script; (2) Improve the script), after all, playback may not succeed, because it involves parameter association (may also be restricted by authentication and verification)

So this is the end of the recording script?

Obviously not, the author has this question, is to teach you efficient recording script process, how to do?

Jmeter allows you to quickly create test plan templates by clicking on a file or clicking on the second green book icon on the toolbar, selecting a template called Recording, and creating it all the way. It has several advantages: the addition of many default components, the addition of a recording controller to the thread group that can be cleared with one click, and the filter setting by default

2.3 handwritten HTTP script (omitted)

This is nothing to say, one is through the capture tool, two is interface documentation; One step at a time. There is no shortcut.

2.4 scripts for other protocols

How to develop scripts for dubbo, SOAP, MQ, etc.? I won't go into details here, but I'll give you a solution

  1. Dubbo protocol: two schemes, one is Telnet command, the other is the development of jMeter sampler plug-in.

The first can not be reused, used for debugging can;

The second kind of request is difficult, fortunately, others have developed a plug-in, so it is not necessary to repeat the wheel

  1. Soap protocol: JMeter was, and still is, supported with a slight twist.

Jmeter provides templates to quickly create test scripts for SOAP protocols, and don’t waste time trying to record or write them by hand.

Here SOAP Request is just the name, which is actually the HTTP Sampler sampler, soap protocol, AND I recommend soapUI, which is made entirely for SOAP

  1. Mq protocol, are you confused?

The authors are confused, and some projects have never even used a framework like MQ. But there is a way to test it, at Github

Third, summary

It doesn't have to be a lesson. It can also be a problem you encountered during script development, and you have a solution

3.1, problem,

Writing a script, recording a script, can always be done without problems in the process of script development, playback or debugging. That's impossible.

  1. Did the script request succeed?
  2. Did you record the playback successfully?
  3. All right, so is the data in the database?

Jmeter's request to Sampler is a successful response, not a business success.

3.2 JMeter script records garbled characters

The general case is to set the encoding format of the HTTP Sampler request

Second, modify the encoding format of sampler in jmeter.properties configuration file

The third is to add the preprocessor specified encoding format

The above three methods are used to solve the response garbled, post request input Chinese result garbled; This is a record entry that’s garbled, right?

The author tried several methods, but nothing came of them. The only solution was to download the latest 5.4.1 version from JMeter’s official website.

There is a way to encode the recording components, and the new UI looks a lot nicer, more subtle, and feels better.

3.3. Is the problem solved here?

No, this is just script development, performance testing is still about scenario design. The final script development is as follows:

“Welcome to the discussion in the comments section. The nuggets will be giving away 100 nuggets in the comments section after the diggnation project. See the event article for details.”