JMeter Fundamentals Slides

From Training Material
Revision as of 18:40, 30 June 2014 by Łukasz Walec (talk | contribs) (→‎Functional Testing)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Introduction

Why use JMeter?

  • Zero acquisition cost
  • Low learning curve
  • Versatile
  • Scalable
  • Good support


JMeter is a desktop application, designed to test and measure the performance and functional behavior of Web applications.

Performance Testing

Performance Testing is defined as testing conducted to evaluate the compliance of a system or component with specified performance requirements. Some of its goals include to identify bottlenecks in a system.


Load Testing, being a part of Performance Testing, is simply the process of subjecting a component or a whole system to a work level approaching its limits.


Load Testing is performed within the capacity of a resources, while Stress Testing is normally performed to evaluate the performance of resources and behavior at full capacity.


In summary, both Load Testing and Stress Testing are part of what makes Performance Testing.

Preparations

It is advised that any form of performance testing should be performed on a functionally stable application. You must be able to identify the general expectations.


Important expectations:

  • A suitable time
  • The performance metrics
  • Objectives of the test


How to get better results?

  • Use meaningful test scenarios
  • Run tests on a dedicated machine
  • Ensure that you have sufficient resources
  • Use Timers
  • Run tests under controlled environment
  • Let tests run for long time periods

Features

JMeter is by far, one of the most widely used open-source, freely distributed testing application.


In order to test and measure the robustness of an HTTP server or network, testers need to provide simulation of multiple and different types of loads.


JMeter allow you to make better analysis of performance under heavy loads.


If you need to further test the functional behavior of applications, JMeter can perform regression tests.

GUI

The left panel displays the elements used in our testing.


The right panel displays the details of each selected element.


A Test Plan describes a series of steps JMeter will execute once the Test Plan runs.


A WorkBench is a temporary workspace to store test elements.

Test Plan

A Test Plan defines and provides a layout of how and what to test. It can be viewed as a container for running tests.


Here you can define static variables that allow you to extract repeated values throughout your tests.

Elements

The most basic JMeter Test Plan may involve creating a loop that simulates sequential requests to the server with a predefined interval and a Thread Group that simulates a concurrent load.


The basic JMeter Test Plan may include at least three elements:

  • Thread Group
  • Listeners
  • Samplers


A typical Test Plan will consist of one or more:

  • Thread Group
  • Listeners
  • Controllers
  • Timers
  • Configuration Elements

Thread Group

While using JMeter as a performance test tool, an essential element is the Thread Group.


A Thread Group represents a group of users that will execute a particular test case.


Elements must be placed under a Thread Group.

Controllers

JMeter has two types of Controllers:

  • Samplers
  • Logic Controllers


Samplers allow you to define the requests that can be sent to a server. You can customize each Sampler by setting its properties, or you can add Configuration Elements.


If you want to perform validation, you may add Assertion elements.


Some useful JMeter Samplers:

  • HTTP Request
  • JDBC Request
  • Debug Sampler


Logic Controllers let you define the order of processing Samplers in a Thread. Several Logic Controllers can be combined to achieve various results.


Some useful JMeter Logic Controllers:

  • Simple Controller
  • Loop Controller
  • Once Only Controller
  • Random Order Controller
  • Interleave Controller
  • If Controller
  • ForEach Controller

Listeners

Listeners let you view the results of the Samplers in the form of tables, graphs, trees or simple text in log files. Each Listener displays the response information in specific way.


A Listener can use a lot of memory if there are a lot of Samples.


Some useful JMeter Listeners:

  • Graph Results
  • Assertion Results
  • View Results Tree
  • View Results in Table
  • Simple Data Writer
  • Aggregate Graph
  • Summary Report

Timers

A Timer Component causes JMeter to pause for a certain amount of time between two successive requests that a Thread Group makes.


You need to take care not to add too many Timers to a Thread Group, as JMeter will pause between two requests for the sum of all Timers found in a Thread Group.


Some useful JMeter Timers:

  • Gaussian Random Timer
  • Poisson Random Timer

Assertions

Assertions allow you to include some validation test on the response of your request made using a Sampler. They are inserted as a child element of a Sampler.


Some useful JMeter Assertions:

  • Response Assertion
  • Duration Assertion
  • XPath Assertion

Configuration Elements

Configuration Elements allow you to create defaults and variables to be used by Samplers.


They are executed at the start of the scope of which they are part, before any Samplers that are located in the same scope. Therefore, a Configuration Element is accessed only from inside the branch where it is placed.


Some useful JMeter Configuration Elements:

  • HTTP Request Defaults
  • HTTP Cookie Manager
  • JDBC Connection Configuration
  • User Defined Variables

Functional Testing

Although JMeter is known more as a Performance Testing tool, Functional Testing elements can be integrated within the Test Plan.


You can also create a Test Plan that runs functional test exclusively.


JMeter does not have a built-in Web browser, unlike many other tools. This makes it difficult to test the GUI of an application.


However, JMeter allows you to create assertions based on the tags and text of the page as the HTML file is received by the client. With some knowledge of HTML tags, you can test and verify any elements as you would expect them in the Web browser.