Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers

Would a middle ground between unit and integration tests be optimal

submited by
Style Pass
2024-11-18 10:00:03

Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams

I've read many posts about unit tests only testing one object/class and mocking of objects should only be for direct dependencies of the object under tests. The only other option discussed for testing are full integration tests.

Why isn't there encouragement for higher level "unit" testing that tests multiple objects at a time? If an application that has components A, B, and C and the application is supposed to do X, Y, and Z, then create tests for X, Y, and Z. This would exercise the code for A, B, and C components.

If there is code in A, B, or C that is not covered by the X, Y, and Z tests, then either that code is not needed or additional high level tests should be added. If needed, low level unit tests for A, B, or C could be added to augment the X, Y, and Z tests.

Leave a Comment