apache / jmeter

Apache JMeter open-source load testing tool for analyzing and measuring the performance of a variety of services
https://jmeter.apache.org/
Apache License 2.0
7.97k stars 2.02k forks source link

Add fail option for regex extractor #6256

Open jgaalen opened 1 month ago

jgaalen commented 1 month ago

Description

This change adds the option to automatically fail a sampler if a regular expression extraction can't find any matches.

Motivation and Context

This saves the need to add an assertion with a regex to be sure there are matches. This will either save doing the regex matching twice and/or improved the scripts by failing if the extraction fails rather fail later when there is no value

Based on this discussion. Thanks to @asfimport for initiating this and providing code

How Has This Been Tested?

I've tested this on HTTP Requests only with different types of matches (1: single extraction, 0: random and -1 to match multiple fields)

Screenshots (if appropriate):

Types of changes

Checklist:

jgaalen commented 1 month ago

Have you considered adding test case for the feature?

Not really, I'm not really into this. I've tried to make something out of an earlier existing (working) code for this feature as you've asked me to create a PR and would love this feature in JMeter, but I'm not a java developer. Can you help me out?