问题
I created JMeter test when I use JDCB query which returns NUMBER value which I set to variable e.g. called employeeID.
I know that it is possible to use Response Assertion and I can verify if my variable: employeeID_1 is equal to specific expected value.
How can I verify if my variable is > 0 instead?
回答1:
The most straight forward would be using BeanShell Assertion like this:
int myNumber = -1;
try {
myNumber = Integer.parseInt(vars.get("employeeID_1"));
} catch(NumberFormatException e)
{ /* Continue to verification with default value */ }
if(myNumber <= 0) {
Failure = true;
FailureMessage = "Expected value to be above 0, but got " + myNumber;
}
回答2:
Even though it's not the components purpose I used the Size Assertion component by using the JMeter variable
field and the >
option with the value 0
. So far I haven't found a reason why not to use this component for testing variables.
来源:https://stackoverflow.com/questions/34770070/how-to-verify-in-jmeter-that-specific-variable-set-by-jdbc-request-is-higher-tha