Operations 6 min read

Master JMeter: Step‑by‑Step Guide to Automate Weather API Load Testing

This tutorial walks you through installing JMeter, creating a Thread Group, configuring HTTP requests, adding headers, listeners, assertions, variables, and correlation to fetch weather data from a public API, providing screenshots and a complete script so you can replicate the load test yourself.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master JMeter: Step‑by‑Step Guide to Automate Weather API Load Testing

JMeter Introduction

JMeter is an open‑source, Java‑based testing tool used for functional and performance (stress/load) testing, especially effective for testing RESTful APIs.

How to Learn JMeter

To use JMeter for web functional or performance testing, you need a solid understanding of the HTTP protocol; otherwise many JMeter concepts will be hard to grasp.

Download and Run JMeter

Official website: http://jmeter.apache.org/

After extracting the archive, run bin/jmeter.bat. JMeter supports Chinese; select the language via Options → Choose Language.

Practical Example: Weather API

Goal: Retrieve weather data for a city.

Step 1: Send a request to obtain the city code, e.g. http://toy1.weather.com.cn/search?cityname=上海. The response contains the city code such as 101020100.

Step 2: Use the city code to request weather data, e.g. http://www.weather.com.cn/weather2d/101020100.html.

Step 1 – Create a Thread Group

All JMeter tasks must be placed under a Thread Group.

Step 2 – Add an HTTP Request

Configure a GET request to http://toy1.weather.com.cn/search?cityname=上海 as shown in the screenshot.

Step 3 – Add HTTP Header Manager

Select the HTTP Request, right‑click, Add → Config Element → HTTP Header Manager, then add the required header.

Step 4 – Add View Results Tree Listener

This listener shows the execution results.

Step 5 – Run Test and View Results

At this point the test runs successfully.

Step 6 – Add Assertion and Assertion Results

Right‑click the HTTP Request, Add → Assertions → Response Assertion, then define patterns to test. Add an Assertion Results listener to view failures.

Step 7 – Use User Defined Variables

Define a variable (e.g., city) via Thread Group → Add → Config Element → User Defined Variables, then reference it as ${city} in the HTTP Request.

Step 8 – Correlation (Extracting Data)

Use a Regular Expression Extractor on the first HTTP Request to capture the city code into a variable (e.g., ${citycode}), then use that variable in a second request: http://www.weather.com.cn/weather2d/${citycode}.html.

With the script complete, run it to see the final results.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JMeterTutorialAPI testing
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.