This is not a unit test for purists (rather an integration test), but still it can be a completely subtle test :-) And technically you can run it using JUnit (or depending on your favorite unit testing system) so IMHO the difference is only in terminology .
If you write your code from scratch, it’s best to start by writing unit tests for individual methods in isolation (dependency bullying), and then in the next step, perhaps add higher-level integration tests, such as those that you describe, to make sure that your classes work well together.
However, in older projects (i.e. a lot of legacy code without tests) it is often impractical to start with fine-grained low-level unit tests; instead, it’s more efficient to write more complex and more complex tests that refine and “block” the behavior of the larger component.
Unfortunately, most of the projects in this industry today are a legacy :-( For me, in these cases, pragmatism wins for the cleanliness of the hands-down approach :-)
source share