How to verify in JMeter that specific variable set by JDBC Request is higher than 0?

*爱你&永不变心* 提交于 2019-12-11 10:52:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!