Way to assert dbfit test empty result is right

1.6k views Asked by At

I am using dbfit and encounter a problem. A big part of the tests I am doing are querys that shouldn't return any results. But when I leave the result rows empty, and executing the test dbfit tells me that ther was zero right result and zero wrong.

So I am looking for a way that dbfit will tell me that the test was right if their was no result returning.And if any result was showing I could see them(so not using assert with a count of zero)

I have tried the fail[expected result] method but it seems that dbfit regarding it like the result to assert with the returning rows from the query.not like a saved method.

So what I can do? Thanx

2

There are 2 answers

0
benilov On

What should work for you is the QueryStats table (sorry, it's not documented but there are some examples in the acceptance test suite):

!|Query Stats                                        |
|query                        | row count? |is empty?|
|SELECT * from dual where 0=1 | 0          |true     |
0
UberDoodles On

I know I'm three years late to the party, but just thought I'd post an alternative answer in case anyone else comes across this.

At first I was going to implement benilov's approach, but then it occurred to me there was a simpler way. Just select the count of records from the table and assert that, rather than trying to select any data :

!|query|!-select count(*) RowCount from table where 0=1-!|
|RowCount?|
|0        |