How to unit test an SQL query?

前端 未结 4 1006
耶瑟儿~
耶瑟儿~ 2021-02-08 11:47

I have a class DBHandler which takes a query, runs it through the SQL server, checks for errors and returns the result. How can I unit test this class?

4条回答
  •  深忆病人
    2021-02-08 12:40

    Just pass a SQL query, and compare the returned result to expected result. Simple. JUnit is a unit test framework, you can utilise that.

    For sophisticated database unit testing, look at DBUnit.

提交回复
热议问题