cancel
Showing results for 
Search instead for 
Did you mean: 

Unit Testing vs Integration Testing a Data Service (NodeJS)

Hi

 

Hi,

I was hoping for further advice on testing my NodeJS backend.

I have a "service" class that saves Social Group details to a database. This uses the Prisma Client as a data layer.

I am aware of the differences between Unit and Integration tests - regarding mocking, differences in speed/purpose re: code design. This is perhaps most understandable with "logic" classes, where I can test business rules in isolation. However, for a "data" service with minimal logic and mostly data access, I'm struggling to grasp the boundaries of Unit vs Integration. There seems to be significant duplication in test cases, which is negatively impacting test maintainability.

1 REPLY 1

Something recently occurred to me. Nobody I know who talks about microservices also talks about integration testing and the effect it has on timelines.

By integration testing I don't mean "my service can talk to the database I created at the same time". That's important, but that's not 'real integration testing', that just testing.

What I mean by integration testing is taking your dozens microservices created by various teams, running them all at once, and have them actually talking to each other. No mocks or other cheats, actual communication just like how it will run in projection.

That type of testing is hard and expensive. But it needs to be done or you're in for a nasty surprise when UAT testing starts.

But have any of you actually included it into timelines? Do you ever reject microservices in favor of monolith because you don't think you can afford the testing overhead?