I am setting some values in database using REST request via JMeter and I want to verify the set values are committed into database. I'm able to access mysql database using JDBC driver in JMeter however I don't know how to compare the output? The JDBC output is shown within JMeter.
1 Answer
You need to use one of JMeter Assertions which are designed to check if returned data matches your test case.
I would do it as follows:
- Update something via REST API call by using a JMEter variable i.e. EXPECTED
- Fetch information from the database via JDBC Request and store in to another JMeter variable, i.e. ACTUAL
- Use i.e. Beanshell Assertion to compare 2 variables.
Example Beanshell Assertion code:
String expected = vars.get("EXPECTED");
String actual = vars.get("ACTUAL");
if (expected.equals(actual))
{
Failure = false;
}
else
{
Failure = true;
FailureMessage = "Difference detected, expected: " + expected + " and actual: " + actual;
}