I am trying to approve BSF using javascript in JMeter.
In JMeter Debug Sampler, I have these two variables: insert_date = 2013-11-11 16: 22: 33.000343 db_created_date_1 = 2013-11-11 16: 22: 53.863187
and I want to compare them to see if they occurred within a certain period of time plus or minus 10 seconds from each other - or if the time difference is more than 20 seconds.
What is the best way to do this?
I do not know whether to use Date.parse (dateVal) The Date.parse function returns an integer representing the number of milliseconds between midnight, January 1, 1970 and the date specified in dateVal.
I tried this with BSF Assertion - javascript, but it does not work:
if ((vars.put("my1",Date.parse(vars.get("db_created_date_1"))) - vars.put("my2",vars.get("insert_date"))) != 0) {
AssertionResult.setFailure(true);
AssertionResult.setFailureMessage("ERROR: The difference between db_created_date value (${db_created_date_1}) ${my1} and the dateTime (${insert_date}) ${my2} is too great.");
}
Validation result: Validation error: false Validation error: true Confirmation error message: ERROR: Difference between db_created_date (2013-11-11 16: 22: 53.863187) NaN and dateTime (2013-11-11 16: 22: 53.863187) NaN too big.
source
share