hi
I'm using Jmeter for testing a local app and I found that the If
Controller doesn't behave as I expected. The expected behavior is that
it evaluates the condition once per child element, or just once?. I
dived into the code and I found that the If controller evaluates the
condition for each sampler (option B. see below) . I read the javadocs
and it's still not clear, it says
<snip>
* it will execute the set of statements
* (samplers/controllers, etc) while the 'condition' is true.
* In a programming world - this is equivalant of :
* if (condition) {
* statements ....
* }
</snip>
A.
if (condition) {
statements....
}
is different from
B.
while (condition) {
next statement
}
Personally, I'd prefer option A. rather than B. WDYT?. I attach a patch.
The patch adds an instance variable that holds the result obtained on
the first evaluation.
BR,
edgar
Index: IfController.java
===================================================================
RCS file:
/home/cvspublic/jakarta-jmeter/src/core/org/apache/jmeter/control/IfController.java,v
retrieving revision 1.11
diff -u -r1.11 IfController.java
--- IfController.java 12 Jul 2005 20:51:00 -0000 1.11
+++ IfController.java 11 Aug 2005 06:43:42 -0000
@@ -50,6 +50,8 @@
private final static String CONDITION = "IfController.condition";
+ private Boolean result = null ;
+
/**
* constructor
*/
@@ -143,8 +145,11 @@
* the iteration even starts !
*/
public Sampler next() {
- boolean result = evaluateCondition(getCondition());
- if (result)
+ if (this.current==0)
+ {
+ result = new Boolean(evaluateCondition(getCondition()));
+ }
+ if (result.booleanValue())
return super.next();
else
try {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]