✅ testing EF CRUD functions
Is it worth trying to do?
And if so should I mock the database and use unit tests or should i make integration tests?
Most of the calls are fairly simple with a few relationships, there is however at least one function with a more complicated relationship between 6 tables where parts have to be converted to a viewmodel
10 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I'd end up with a lot of those though
And wouldn't I need seperate test database
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Not sure I can, need to talk to my senior dev colleague about the servers
Anyway thanks for the help
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
My question is why are you unit testing or thinking you need to unit test the database?
Unit tests are for business logic
Database is like 500 tables
I'm not sure how else to test my different actions without having the testers do all the work
But is there business logic in the database? If so, why? If not, why does the database matter for unit tests. If business logic is properly isolated, there should be no need for the db to test it
Yeah there are some triggers, sadly
So you're suggesting just skipping testing CRUD?
Mhm so just extract all the logic that actually does things with the objects and just test on that and ignore the EF on the database
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.