How to unit test an SQL query?

前端 未结 4 1013
耶瑟儿~
耶瑟儿~ 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:38

    You'll want to either use an in-memory test database that you create and populate on set-up or make all your tests transactional so they don't alter your test database.

    You'll have to worry about the presence of data.

    If you're using Spring, they have support for transactional unit tests.

    It's not clear what you're asking. You already know about JUnit. What do you think you're missing?

提交回复
热议问题