0
votes

I want to compare(assert maybe) some values from "User defined variables" with values obtained from DB query using "JDBC Request" in jMeter, the thing is after i do the SELECT query i get only the column names and not the values. How can i do this comparison step by step? Thank you!

2

2 Answers

1
votes

For instance, MySQL server has "mysql" database. In this database there is a "help_keyword" table which looks as follows:

MariaDB [mysql]> describe help_keyword;
+-----------------+------------------+------+-----+---------+-------+
| Field           | Type             | Null | Key | Default | Extra |
+-----------------+------------------+------+-----+---------+-------+
| help_keyword_id | int(10) unsigned | NO   | PRI | NULL    |       |
| name            | char(64)         | NO   | UNI | NULL    |       |
+-----------------+------------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

So if you configure your JDBC Request to select first row as

select * from help_keyword limit 1;

It'll return the following:

help_keyword_id name
0   JOIN

For instance you need to assert this JOIN keyword. To do so:

Add User Defined Variables configuration element and define KEYWORD variable with the value of JOIN

User Defined Variable

Add JDBC Request configured as follows:

  • Query Type
    • Select Statement
  • Query
    • select * from help_keyword limit 1;
  • Variable names
    • id,name

JDBC Request

Add Response Assertion as a child of JDBC Request configured as follows:

  • Apply to
    • JMeter Variable: name_1
  • Patterns to Test
    • ${KEYWORD}

Response Assertion

Test Plan above will perform whether 1st row of "name" column value equals JOIN

See How to Use JMeter Assertions in 3 Easy Steps guide for more information on how JMeter Assertions can be used.

0
votes

Use "Response Assertion" for your JDBC request.
Select the below mentioned properties of "Response Assertion":

  • Apply to: "Jmeter Variable" e.g. ${value}, where value is User Defined variable.
  • Response field to test: "Text Response"
  • Pattern Matching Rules: As per your requirement.

Hope this will help