Java Tutorial - Java Script : Test Plans

Java Tutorial - Java Script :

Test Plans


The first thing a test plan needs is a thread group. Thread groups represent groups of virtual users; each thread corresponds to another user of the system.Each thread group will prompt you for a number of threads, a ramp-up period, and a loop count. The ramp-up period is divided evenly among all the users. Remember that each threadcounts as one virtual user, so if there are five threads and a ramp-up time of five seconds, the users will ramp up at an approximate rate of one new user per second. To a thread group, we can add:

Configuration elements: Configuration elements are helpers that provide support for samplers within the same subtree. Some of the uses of configuration elements include setting default values for samplers and collecting and storing cookies for Web requests.

Logic controllers: Logic controllers provide a means to customize the logic that is used by jMeter to decide when to send requests. Logic controllers can also be thought of as containers for other testing elements. The elements within the container are executed according to the rules of the logic controller. An example of a logic controller is the Once Only controller. Once Only executes the samplers within the controller only once during the test plan. This is useful for situations such as site logins,where the user should only login once.

Listeners: Listeners provide access to the information collected as jMeter runs. Listeners can be used to display the data graphically or to save the results in a file.

Samplers: Samplers are used to collect information for jMeter. Samplers exist for sending requests to the server and collecting responses. There are samplers for testing Web applications, Web services, JDBC, and FTP requests.

Assertions: Assertions are not added to a thread group but are added to samplers. Assertions are added to test if the response from the server was the expected response.

Timers: Timers are used to provide delays between requests. jMeter sends requests one immediately after another by default. A timer adds a delay between requests on a thread or by a virtual user. For a quick demonstration, the following instructions show you how to perform a quick test of the Tomcat index.html page.

1. Start by adding a thread group and naming it TomcatUsers. Set the number of threads to 5, the ramp-up period to 0, and the loops to 2.
2. To this thread group, add these three config elements:

·         HTTP Request Defaults
·         HTTP Cookie Manager
·         HTTP Header Manager
3. Edit the HTTP Request Defaults so that the server is the server where Tomcat is installed and the port is the port configured for Tomcat requests (normally Tomcat uses port 8080 by default). The values set here will become the default values for all HTTP request samplers that we will add later. No changes need to be made for the cookie or header managers.
4. Add a logic controller to the thread group. To do this, select the TomcatUsers Node and add the “Simple Controller” from the Logic Controllers menu. This controller isn’t strictly required but it serves as a container for the samplers that we will add shortly.
5. Add an HTTP request sampler to the Simple Controller. To do so, in the path field just enter a “/” and select the GET request button.
6. Next, you need a listener. (Remember, a listener provides access to the data collected by samplers. If a listener is not present, then there will be no way to observe anything as the test progresses.) Because you will be running just a small number of samples, you can use the View Results In Table listener. You can add the listener directly to the TomcatUsers node. If you want to save the data and share it across listeners, you should provide a filename in the Write All Data to a File portion of the panel. Providing a filename here also allows you to view the results in other listeners after you have executed the test.
7. You are now ready to run the test. To do so, choose Run Start. A small green square at the top-right corner of the window indicates that a test is currently in progress. If the View Results in Table node is selected, the results of each test will be added as the tests are completed. If the individual tests are successful, then a check mark will appear in the rightmost column of the result table.