0Pricing
Load Testing & Performance Benchmarking (JMeter & k6) · 강의

동적 값 처리(상관관계)

정규 표현식 추출기를 사용하여 서버 응답에서 동적 값을 추출하고 재사용하는 방법을 학습합니다.

동적 값 처리(상관관계)은(는) CoddyKit의 무료 Load Testing & Performance Benchmarking (JMeter & k6) 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Load Testing & Performance Benchmarking (JMeter & k6) 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Load Testing & Performance Benchmarking (JMeter & k6) 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Dynamic Values Explained

When you interact with a web application, many values in the server's responses aren't static. These are called dynamic values.

They change with each user, session, or even each request. Think of them like temporary keys the server gives you.

  • Session IDs
  • Authentication Tokens
  • CSRF Tokens

Why Correlation is Essential

If your performance test simply records and replays requests, it often fails. Why?

Because the recorded requests contain old, invalid dynamic values. The server rejects them, thinking you're not a legitimate user or session.

Correlation is the process of extracting these dynamic values from one response and reusing them in subsequent requests.

Meet the Regex Extractor

JMeter provides a powerful tool to handle dynamic values: the Regular Expression Extractor.

This Post-Processor component allows you to define a pattern (a regular expression) to search within a server's response and capture specific data.

It's like telling JMeter: "Find this pattern, and grab whatever is inside these brackets!"

How Extraction Works

Here's the basic flow for using a Regular Expression Extractor:

  1. Send Request: Your JMeter sampler sends a request to the server.
  2. Receive Response: The server sends back a response, which contains the dynamic value.
  3. Extract Value: The Regular Expression Extractor scans the response for your defined pattern.
  4. Store Value: It captures the dynamic data and stores it in a JMeter variable.
  5. Reuse Value: You then use this variable in subsequent requests.

Regex Basics for Extraction

A Regular Expression (Regex) is a sequence of characters that defines a search pattern. For extraction, you'll often use:

  • . (dot): Matches any single character.
  • * (asterisk): Matches zero or more occurrences of the preceding character.
  • ? (question mark): Makes the preceding quantifier (like *) non-greedy, matching the smallest possible string.
  • () (parentheses): Used to capture the part of the string you want to extract.

Try running this simple JavaScript example to see regex in action:

function extractId(text) {
  // Regex to find "id=" followed by one or more digits
  // and capture the digits.
  const regex = /id=(\d+)/;
  const match = text.match(regex);
  return match ? match[1] : null;
}

console.log("Extracted ID:", extractId("user?id=123&name=test"));
console.log("Extracted ID:", extractId("product?id=456"));
console.log("Extracted ID:", extractId("no_id_here"));

Adding the Extractor

In JMeter, the Regular Expression Extractor is a Post-Processor. This means it runs after a sampler (request) completes but before the results are recorded.

To add it:

  1. Right-click on the HTTP Request (or other sampler) that receives the dynamic value.
  2. Go to Add > Post-Processors > Regular Expression Extractor.

It will become a child of that specific request.

Extractor Configuration

The Regular Expression Extractor has several key fields:

  • Reference Name: The name of the JMeter variable to store the extracted value (e.g., sessionId).
  • Regular Expression: The actual regex pattern to match (e.g., name="sessionId" value="(.+?)").
  • Template: How to construct the value. Use $1$ for the first captured group, $2$ for the second, etc.
  • Match No.: If multiple matches, which one to use? 0 for random, 1 for first, -1 for all (creates multiple variables).
  • Default Value: A value to assign if the regex doesn't find a match.

Using the Extracted Variable

Once the Regular Expression Extractor stores a value in a variable (e.g., sessionId), you can use it in any subsequent JMeter sampler or component.

To reference the variable, use the syntax ${ReferenceName}.

For example, if you extracted a session ID into sessionId, you might use ${sessionId} in the body or URL path of a follow-up request.

A Correlation Scenario

Consider a login sequence:

  1. Request 1 (Login): Sends username/password.
  2. Response 1: Contains a CSRF_Token in a hidden field.
  3. Regex Extractor: Extracts CSRF_Token from Response 1 and stores it in ${csrfToken}.
  4. Request 2 (Submit Form): Uses ${csrfToken} in its request body or URL parameters.

This ensures your test script behaves like a real user, passing the dynamic token.

Test Your Regex Knowledge

Imagine a server response contains the following HTML snippet:

<input type="hidden" name="token" value="abc123xyz456" />

You want to extract the value abc123xyz456 into a JMeter variable named authToken.

Which Regular Expression and Template combination should you use in the Regular Expression Extractor?

Recap: Mastering Correlation

Great job! You've learned the critical skill of correlation in JMeter.

  • Dynamic values require special handling to prevent test failures.
  • The Regular Expression Extractor is JMeter's primary tool for this.
  • You define a regex pattern to capture specific data from server responses.
  • Extracted values are stored in JMeter variables for reuse in subsequent requests.

This technique makes your performance tests robust and realistic. Next, we'll explore more JMeter functions and variables for even greater script flexibility!

자주 묻는 질문

“동적 값 처리(상관관계)” 강의는 무료인가요?

네 — “동적 값 처리(상관관계)” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Load Testing & Performance Benchmarking (JMeter & k6) 강의 전체를 잠금 해제할 수 있습니다. Load Testing & Performance Benchmarking (JMeter & k6) 강의에는 총 4개의 강의가 포함되어 있습니다.

“동적 값 처리(상관관계)”에서 뭘 배우나요?

정규 표현식 추출기를 사용하여 서버 응답에서 동적 값을 추출하고 재사용하는 방법을 학습합니다. 브라우저에서 직접 실행하는 실습 코드로 Load Testing & Performance Benchmarking (JMeter & k6)을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Load Testing & Performance Benchmarking (JMeter & k6)을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Load Testing & Performance Benchmarking (JMeter & k6)은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.

“동적 값 처리(상관관계)” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Load Testing & Performance Benchmarking (JMeter & k6) 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Load Testing & Performance Benchmarking (JMeter & k6) 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. CSV 데이터로 매개변수화
  2. 동적 값 처리(상관관계)
  3. JMeter 함수와 변수
  4. JDBC를 사용한 데이터베이스 시험
← Load Testing & Performance Benchmarking (JMeter & k6)(으)로 돌아가기