jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kyle McAbee" <k.mca...@treev.com>
Subject RE: nesting constants/variables between two groups in template
Date Tue, 23 Nov 2004 19:28:59 GMT
Dear Praveen and JMeter Users:

This approach works for me when trouble-shooting a regular expression in JMeter:

1. Check the regular expression with a regular expression tester. This provides a test independent
of JMeter. Rewrite the regular expression, if needed.

2. In the Regular Expression Extractor, check for interactions between the Template parameter
and the Match No. parameter. There is more than one way to extract the same string, and some
ways are simpler than others.

The Match No. parameter controls whether JMeter stores a particular match or all matches.
If set to a positive integer, JMeter stores the particular match (1, 2, ...) and its groups
in a set of predefined variables. The whole match is stored in refname_g0. The first group
is stored in refname_g1, the second group in refname_g2, and so on.

However, if the Match No. parameter set to a negative number like -1, JMeter stores all matches
and groups, and stores them in a different set of predefined variables (refName_matchNr, refName_n,
refName_n_gn ...). For example, the second whole match's third group would be stored in refName_2_g3.

In the Template parameter, the predefined variable $0$ sets the value of the variable to the
whole match. The predefined variables ($1$, $2$, $3$, ...) can set to variable to groups in
the match. You can also put arbitrary strings in the Template parameter, as Praveen did with
"CONSTANT".

Here is example of an interaction that might not give you the result you would want. Define
a Regular Expression Extractor as follows:

Reference Name: Result
Regular Expression: (Go)(ogle)
Template: $0$
Match No.: -1
Default Value: NoResult

The value of ${Result} is "NoResult". If Match No. is set to -1, you must use the one of the
"all matches" predefined variables to get the first whole match: Result_1 (refName_n).

The new user manual and new help with JMeter 2.0.2 are improved from version 2.0.1.

3. Check the variable values while the test plan is running.

Here is a quote from our internal JMeter documentation for testers:
----------------------------
Checking variables while test plan runs (JMeter)
Problem
You want to check that variables have the expected values while JMeter runs the test plan.
The variables could be defined in an element (User Defined Variables element, User Parameters
element, Regular Expression Extractor element) or by a function (__regexFunction). A variable
value could be hard-coded, constructed from one or more variable values, or extracted from
an HTTP response by a regular expression.
Solution
To display a variable value while a test plan is running, follow these steps.
1.	Add a Java Request element (a Sampler) to the test plan after the point in the test plan
where the variable is defined by an element or a function.
2.	In the Java Request, do the following:
a.	Set the Label parameter to display the variable name and variable value. For example:
	MyVariable: ${MyVariable}
b.	Set the Status parameter to "OK" or "FAIL".
	"OK" allows the test plan execution to continue.
	"FAIL" forces test plan execution to stop.
3	Add a View Results in Table element (a Listener) to the test plan.
4.	Run the test plan.
	The View Results in Table element displays the Java Request response with the variable name
and variable value.
----------------------------

Might a "How can I trouble-shoot a regular expression in JMeter?" topic be a useful addition
to the FAQ?

Sincerely yours,

Kyle

-----Original Message-----
From: praveen [mailto:pkallakuri@gmail.com]
Sent: Tuesday, November 23, 2004 1:05 PM
To: JMeter Users List
Subject: nesting constants/variables between two groups in template


I have a regex 

(rex1)(rex2)(rex3)

The template looks like

$1$CONSTANT$3$


But the result I see is: 

$1$$2$CONSTANT

Even if I replace the CONSTANT with some variable, the same thing happens. 

I am using 2.1.20041011 (build from src). Is it a bug or am I doing
something wrong?

thanks

-- 
                                     k.p.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Mime
View raw message