7 ms·
A class should do one thing and do it well. It should be just as long as it needs to be. A unit is not test for a 500 error, that usually an integration test,
by logn 14y ago
A class should do one thing and do it well. It should be just as long as it needs to be.
A unit is not test for a 500 error, that usually an integration test, testing end-to-end functionality.
A unit can be as small as a single method. In Java, generally only public methods are tested. Units can be bigger, but you should be attempting to test the smallest unit of functionality you can. So start with testing a method and if that's not possible go higher.