Skip to content
Tutorials Center
My learning

Topics

Lesson 4 of 37 ยท Getting Started

Your First JMeter Test Plan: Build, Run and Read Results

Build a first JMeter test plan with a Thread Group, an HTTP Request, an assertion and a listener, run it in the GUI, then run it from the command line and read the results.

In this lesson you build a complete, working test plan in about ten minutes: a Thread Group, an HTTP request, a check, and a results listener. You then run it two ways. The target is a site you own or have permission to test. Never aim a load test at someone else's server; even a small test can look like an attack.

Honesty note. JMeter cannot run on this website, so the steps describe the GUI exactly and the file shown is the structure of a .jmx plan. The runnable block is a stand-in that models a plan as data and "executes" it against a fake server, so you can see how threads, loops and assertions combine.

The plan we will build

flowchart TD
  TP["Test Plan: First Test"] --> TG["Thread Group: 5 users, ramp-up 5 s, loop 3"]
  TG --> D["HTTP Request Defaults: server + port"]
  TG --> R["HTTP Request: GET /"]
  R --> A["Response Assertion: code 200"]
  TP --> L["View Results Tree + Summary Report"]

Request count: 5 users x 3 loops x 1 request = 15 samples.

Step 1: Add a Thread Group

  1. Start JMeter in GUI mode. The left tree shows Test Plan.
  2. Right-click Test Plan and choose Add > Threads (Users) > Thread Group.
  3. Set Number of Threads (users) to 5, Ramp-up period (seconds) to 5, and Loop Count to 3 (untick Infinite).

Ramp-up means JMeter starts the 5 threads evenly across 5 seconds, one per second. A ramp-up of 0 starts them all at once, which is a spike, not a gentle load.

Step 2: Add an HTTP Request

Right-click the Thread Group and choose Add > Sampler > HTTP Request. Fill in:

  • Name: Home page
  • Protocol: https (or http)
  • Server Name or IP: your host, for example staging.example.test
  • Path: /
  • Method: GET

A sampler is the element that actually sends a request and produces a sample (one result row). Everything else in a plan either feeds samplers or processes their results.

Step 3: Add an assertion

By default JMeter calls a response successful when the HTTP status is below 400. Be stricter: right-click the HTTP Request and choose Add > Assertions > Response Assertion. Set Field to Test to Response Code, Pattern Matching Rules to Equals, and add 200 under Patterns to Test. A response with any other code is now marked as failed.

Step 4: Add listeners

Right-click the Thread Group (or the Test Plan) and add two listeners via Add > Listener:

  • View Results Tree shows every request and response: ideal for debugging.
  • Summary Report shows a table of count, average, min, max, error % and throughput per request label.

Step 5: Run it and read the results

Save with Ctrl+S as first-test.jmx, then click the green Start arrow. The counters at the top right show active threads and total samples. Click the Results Tree and select a sample: tabs show Sampler result, Request and Response data. A green shield means passed; a red cross means failed.

In the Summary Report, you should see one row Home page with 15 samples (if the loop counts are as above). If Error % is not 0, open the Results Tree and look at the failing response: wrong host, blocked by a firewall, or an unexpected status are the usual suspects.

Before every re-run use Run > Clear All (the broom icon) so old results do not mix with new ones.

What the saved file looks like

The .jmx file is XML. Reduced to its skeleton, it has the same shape as your tree:

XML
<jmeterTestPlan version="1.2">
  <hashTree>
    <TestPlan testname="First Test"/>
    <hashTree>
      <ThreadGroup testname="Users">
        <stringProp name="ThreadGroup.num_threads">5</stringProp>
        <stringProp name="ThreadGroup.ramp_time">5</stringProp>
      </ThreadGroup>
      <hashTree>
        <HTTPSamplerProxy testname="Home page"/>
        <hashTree/>
      </hashTree>
    </hashTree>
  </hashTree>
</jmeterTestPlan>

This is an abbreviated sketch, not a complete loadable file; real files carry many more properties. You almost never edit .jmx by hand, but knowing it is a nested tree helps when reviewing diffs.

Step 6: Run in non-GUI mode

For anything bigger than a smoke test, close the GUI run and use the command line:

Terminal
jmeter -n -t first-test.jmx -l first.jtl -e -o first-report

-l first.jtl writes one line per sample; -e -o first-report builds the HTML dashboard from it into first-report, which must be empty or nonexistent. Open first-report/index.html in a browser. You will learn to read results in Listeners and Results.

A plan as data: stand-in simulation

To make the semantics concrete, this stand-in models the plan as a plain object and runs it against a fake in-memory "server" with a seeded random generator. It computes the same sample count and error rate you would see in a Summary Report.

JS Stand-in: execute a plan model against a fake server

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Change users, loops or the 503 probability and rerun to watch the totals move. The relationship samples = users x loops x samplers is worth memorizing; it is the first thing to check when a report shows an unexpected sample count.

Common beginner mistakes

  • Leaving Infinite loops ticked, so the test never ends.
  • Running with 500 threads in GUI mode with a Results Tree open: the GUI itself runs out of memory.
  • Forgetting to clear old results between runs.
  • Testing localhost with the load generator on the same machine as the server.
  • Having no assertion, so a fast 200 error page counts as a success.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. A Thread Group has 10 threads, loop count 5, and contains 2 samplers. How many samples will be produced?

    10 threads x 5 loops x 2 samplers = 100 samples.
  2. 2. What does the ramp-up period control?

    Ramp-up spreads thread startup over the given seconds, so load builds gradually.
  3. 3. Which listener is best for debugging one request and its response body?

    View Results Tree shows request and response details for every sample.
  4. 4. What must be true of the folder given to -o when generating the HTML report?

    JMeter refuses to write a report into a non-empty folder to avoid mixing runs.

Summary

  • A minimal plan is Test Plan, Thread Group, a sampler, an assertion and a listener.
  • Threads x loops x samplers gives the sample count.
  • Build and debug in the GUI with few threads; run real tests with -n -t -l -e -o.
  • Add an assertion so "fast but wrong" is not counted as success.
  • Test only systems you own or have permission to test.

Next: The JMeter GUI Tour