JMeter Notes 4

Source: Internet
Author: User

JMeter testing Web applications using JMeter in software testing jmeter can be used to test the performance of static or dynamic resources (files, Servlets, Perl scripts, Java objects, databases and queries, FTP servers, or other resources). JMeter is used to simulate the ability to attach high loads on servers, networks, or other objects to test the compression capabilities of their services, or to analyze the overall performance of the services they provide under different load conditions. You can use the graphical interface provided by JMeter to analyze performance metrics or test server/script/object behavior under high load conditions.   using JMeter to test Web Apps in the next section, the author will show you in detail how to use JMeter to test the complete process of a Web application. 2.1 Test Environment The author uses Tomcat as a Web server for testing, the content being tested is a JSP file and a servlet,jsp file calls JavaBean, printing related information, the servlet accepts user parameters, calls JavaBean, and outputs relevant information. Please refer to the Jmeter.war content provided by the author for detailed information. 2.2 Installation Start JMeter You can download the release version of JMeter from the JMeter website and unzip the downloaded. zip file to C:/jmeter (which will use%jmeter% to refer to this directory in later articles). Now, use the Jmeter.bat batch file below%jmeter%/bin to start the JMeter visual interface, and the following work will be done on this visual interface. 2.3 The test Plan test plan describes the execution process and steps of jmeter during the execution of the test, and a complete test plan consists of one or more thread groups (thread Groups), logical control (logic controller), The instance generates the controller (Sample generating Controllers), listener (Listener), timer (timer), Comparison (assertions), configuration element (config Elements). When JMeter is opened, it has established a default test plan, and an instance of a JMeter application can only establish or open a test plan. Now that we are populating the content of a test plan, this test plan makes a request to a JSP file and a servlet, we need to jmeter simulate five requestors (i.e. five threads), each requester requests two times in a row, and the following sections describe detailed steps. 2.4 Increasing the Load information setting this step, we will add the relevant load to the test plansetting, is jmeter know we need to simulate five requestors, each requestor requests two times in a row during the test. The detailed steps are as follows: 1. Select the Test Plan node of the left tree in the visual interface, right-click, select Add ' Thread Group, and his Settings information box will appear to the right of the interface. 2. The Thread group has three parameters related to load information: number of Threads: Sets the amount of users sending the request Ramp-up period: The total time interval, in seconds, that occurs for each request. For example, your request number is 5, and this parameter is 10, then the interval between each request is 10/5, that is, 2 seconds loop Count: The number of repetitions of the request, if you choose Forever (the default), then the request will continue, if not select forever, When you enter a number in the input box, the request repeats the specified number of times, and if you enter 0, the request executes once. Based on the design of our demo example, we should set number of threads to 5,ramp-up period set to 0 (that is, concurrent requests), uncheck forever, enter 22.5 in the input box after loop count Add default HTTP properties (optional) The actual test work is often done for Web applications on the same server, so JMeter provides a setting where the default HTTP property settings require the relevant properties of the test server. The settings of these same parameters can be ignored in future HTTP request settings, reducing the time to set parameter entry. We will use this attribute here. You can set the default HTTP properties by using the following steps: 1. Select the Test Plan node of the left tree in the visual interface, right-click and select the Add ' config element ' HTTP request defaults, and his settings box will appear to the right of the interface. 2. The main parameters of the default HTTP properties are described below: protocal: The protocol server name or IP: the IP address of the server being tested, or the name of the path: the default starting location. For example, if path is set to/jmeter, the/jmeter path will be added to all HTTP request URLs. Port number: Server service port numbers our test plan will be tested against a web app on a native Web server, so protocal should be http,ip using localhost, Because this web app publishes a context path that is/jmeter, the path here is set to/jmeter, because using the Tomcat server, so port number is 8080. 2.6 Add HTTP request now we need to increase the HTTP request, and he is also the subject part of our test. You can add a sexual HTTP request by using the following steps: 1. Select the thread group node of the left tree in the visual interface, right-click, select Add ' Sampler ' HTTP request, and his settings information box will appear to the right of the interface. 2. His parameters are about the same as the HTTP properties described in 2.5, and the added attributes have the option of sending HTTP when the method is sent, and you can choose either get or post. We are now adding two HTTP requests because we have set the default HTTP properties, so the same properties as the default HTTP properties are no longer set again. After setting the screen as follows: 2.7 Increase listener increase listener is to record the test information and can use the visual interface provided by JMeter to view the test results, there are several methods of analysis of results to choose from, you can choose different results according to their own analysis method of display , we use tabular form to view and analyze test results. You can add listener:1 by following the steps below. Select the Test Plan node of the left tree in the visual interface, right-click, select Add ' listener ' view result in table, and the right side of the interface will appear with his settings information and the result display box. 2. You can set the FileName property setting on the interface to save the test results to a file interface The test results are displayed using a table, the first column of the table Sampleno shows the order and number of requests executed, the URL shows the target of the request sent, The Sample-ms column shows how long this request will take to complete, and the final success column shows whether the request was executed successfully. The bottom of the interface you can also see some statistics, the most concern should be average bar, that is, the corresponding average time. 2.8 Starting a test plan you can now execute the test plan by clicking the menu bar run-start. Several large time values for the first execution are derived from the JSP request, which can be explained by the following reasons: The JSP needs to be compiled into a. class file before execution. So the second result is the normal result.   Summary jmeter is used for energy or performance testing, and by using the energy provided by the jmeter, we can visualize the test plan: including what kind of load to use, what content to test, what parameters are passed in, and he provides a lot of graphical test results display methods, Allows us to start testing work and analyze test results simply. In this article, the author has demonstrated in detail how to use JM based on his own experience in usingEter the whole process of web testing, it simply introduces the meaning of relevant parameters in the graphical display interface that JMeter provides test results.

JMeter Notes 4

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.