Golang testing - best practices
I'm working on a small web app project, domain driven, each domain has handler/service/repo layer, using receiver method design, concrete structs with DI, all wired up in Main. Mono-repo containerised application, built-in sqlite DB.
App works great but I want to add testing so I can relieve some deployment anxiety, at least for the core features. I've been going around and around in circles trying to understand how this is possible and what is best practice. After 3 days I am no closer and I'm starting to lose momentum on the project, so I'm hoping to get some specific input.
Am I supposed to introduce interfaces just so I can mock dependencies for unit testing? How do I avoid fat interfaces? One of the domains has 14 methods. If I don't have fat interfaces, I'm going to have dozens of interfaces and all just for testing. After creating these for one domain it was such a mess I couldn't continue what genuinely felt like an anti pattern. Do I forget unit testing entirely and just aim for integration testing or e2e testing?
submitted by /u/Chernikode
[link] [comments]