user3358737
user3358737

Reputation: 23

Assertion on JMeter JDBC Request sampler

is it possible for jmeter to do assertion on jdbc request sampler( insert, update, delete) ?
which assertion method should i use to achieve this?

for example:
I have a jdbc connection configuration to database, use jdbc request to do insert statement.
how can i use assertion to check whether the jdbc request insert statement is correctly executed and the row is actually inserted into the table.

Upvotes: 2

Views: 4103

Answers (1)

Laszlo Lugosi
Laszlo Lugosi

Reputation: 3829

There are many solutions for this issue, I will explain one: Create a Thread group first and create a JDBC Connection as first child element of the group.

Create a JDBC Request after the connection, and set the Variable Name same as the connection above.

Select Update Statement in Query type drop down, and place your INSERT script into the Query textarea.

Check INSERT via SELECT

Create another JDBC Request and make a Select Statement and write a query what check your inserted line, for example with

SELECT COUNT(*) AS COU FROM yourtable WHERE id=1

Set the Result variable name to "result"!

Assertion: Than create a BeanShell Assertion on this element and write a script like this:

int count = vars.getObject("result").get(0).get("COU").intValue();
log.info("----- count: " + count);

if (count != 1){
  Failure = true;
  FailureMessage = "Count of rows: " + count;
}

I am not pro in JMeter, so I am sure there are some simple solutions for this kind of problems, but in this way you can do anything.

Upvotes: 3

Related Questions