Getting Started with JMeter Course

Sep 2, 2024

JMeter Master Class Notes

Introduction

  • Instructor: Raghav
  • Aim: Practical course for complete beginners on JMeter from scratch.
  • Resources:

What is JMeter?

  • JMeter is a 100% pure Java application used for load testing, functional behavior, and performance measurement.
  • Website: jmeter.apache.org
  • Requirements: Java on your system to run JMeter.
  • Features:
    • Free and open source.
    • Supports recording of test cases.
    • Command line options available for running tests.
    • Reporting features.

Supported Applications and Protocols

  • Initially designed for web applications but now supports:
    • Web, SOAP, and REST web services
    • FTP
    • Databases (JDBC)
    • LDAP, GMS, TCP, and Mail protocols.
  • JMeter has various plugins available to extend its functionality.

Installing JMeter

  • Check if Java is installed: java -version on Windows or Mac.
  • Download JMeter from jmeter.apache.org.
  • Extract the downloaded zip file and keep it in a desired location.

Starting JMeter

  • On Mac: Run sh jmeter.sh from the bin folder.
  • On Windows: Run jmeter.bat from the bin folder.

GUI Overview

  • Menu Bar: Contains options for File, Edit, Run, Options, Tools, Help.
  • Toolbar: Quick access to frequently used options.
  • Test Plan Tree: Displays all elements of the test plan.
  • Editor Area: For editing the selected element.

Creating Your First Test Plan

  1. Start JMeter and create a New Test Plan.
  2. Add a Thread Group.
  3. Add Samplers (HTTP requests, etc.).
  4. Add Listeners (View Results Tree, etc.).
  5. Configure Thread Group settings (number of users, ramp-up time, loop count).
  6. Save and Run the test.

JMeter Listeners

  • Listeners record and display results of a test.
  • Common Listeners:
    • View Results Tree
    • View Results in Table
    • Aggregate Report
    • Graph Results
    • Summary Report

Assertions

  • Assertions validate responses from the server.
  • Common Assertion Types:
    • Response Assertion (checks status codes, response data)
    • Duration Assertion (checks response time)
    • Size Assertion (checks response size)

JMeter Functions and Variables

  • Functions: Methods used to populate fields in a test plan.
    • Syntax: $__functionName(arguments)
  • Variables: Containers that store values for later use.
    • Syntax: ${variableName}
  • Use functions like log, time, threadNum, etc.

Creating REST API Requests

  1. Use HTTP Request Sampler for REST API.
  2. Set Method (GET, POST, PUT, DELETE).
  3. Add Body Data for POST requests.
  4. Add Header Manager for Content-Type and Authorization.
  5. Add Assertions to validate responses.

Creating SOAP API Requests

  1. Use HTTP Request Sampler for SOAP API.
  2. Set Method to POST.
  3. Add WSDL as a reference for generating request structure.
  4. Add Body Data for the SOAP message.
  5. Add HTTP Header Manager for Content-Type (usually text/xml).
  6. Add Assertions to validate responses.

Running JMeter from Command Line

  • Command: jmeter -n -t <path to .jmx file> -l <path to result file>
  • Generate HTML Reports: jmeter -g <path to result file> -o <output directory>

JMeter Plugins

  • Extend JMeter functionality via plugins.
  • Install plugins via JMeter Plugin Manager.
  1. Download Plugin Manager JAR.
  2. Add to JMeter's lib/ext folder.
  3. Restart JMeter.
  4. Access Plugin Manager from Options menu.

Conclusion

  • Create and run tests for both REST and SOAP APIs in JMeter.
  • Explore and learn more about JMeter features and best practices for performance testing.