简体   繁体   中英

Way to assert dbfit test empty result is right

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

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     |

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        |

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM