5 ms·
In my opinion you should only test the functionality of the code that you're "talking about". Ideally you'll have some component that exposes a `GetX(id)`, `Sav
by gravypod 6y ago
In my opinion you should only test the functionality of the code that you're "talking about". Ideally you'll have some component that exposes a `GetX(id)`, `SaveX(x)`, `FindX(WithName(foobar))` or something. That code should be tested against a mock of the DB. Everything else should use a mock/fake of that API.
This has many reasons why you'd want to do it. Many people stick to "performance" but I think that's the weakest reason. Ideally if you change some code and break something you want the method name of a failed test to tell you what's wrong. If you change some ORM code and 100% of your tests fail, is that helpful? Compared to the case where you change the ORM code and the unit tests testing the ORM code fail?
- lupire 6y agoSQLite is a fake for the remote database. > you change some ORM code and 100% of your tests fail, is that helpful? Yes. It shows what depends on the ORM behavior. Of course you need to be smart about finding the root cause.