Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit testing HQL query

I have something like a HQL-query factory, which produces plain string HQL-queries. How can I unit-test for syntax errors, without doing integration testing with the database by actually executing the query over something?

Best option would be to call some magic VerifyHql() method, or to maybe use it somewhere and catch some meaningful parse exception or something.

like image 848
Denis Biondic Avatar asked May 29 '26 04:05

Denis Biondic


1 Answers

It doesn't make much sense to test a query without a database to query, so these should be tested using integration tests. However, you can use an in memory SQLite database instead of hitting a real server. There's a NuGet SQLite package available.

like image 174
Jamie Ide Avatar answered May 30 '26 19:05

Jamie Ide



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!