How do I compare database values in JMeter

0

1

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.

TusharG

Posted 2013-11-25T10:43:32.030

Reputation: 1 352

Answers

3

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:

  1. Update something via REST API call by using a JMEter variable i.e. EXPECTED
  2. Fetch information from the database via JDBC Request and store in to another JMeter variable, i.e. ACTUAL
  3. 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;
}

Dmitri T

Posted 2013-11-25T10:43:32.030

Reputation: 411