2 ms·
I have just the one use case: to escape out of framework/annotation hell. Say I have a well-designed, self-contained BusinessService class which is perfectly u
by mrkeen 3y ago
I have just the one use case: to escape out of framework/annotation hell.
Say I have a well-designed, self-contained BusinessService class which is perfectly unit-testable.
Then someone comes along and sprinkles some @Magic bullshit on it. Now its true behaviour won't be exercised in plain junit - you need custom test runners with class-path scanning and late-binding configuration ("The gorilla holding the banana and the rest of the jungle" in Joe Armstrong speak).
If you want to reclaim your unit-testable class, you can divide it into two: SpringBusinessService extends BusinessService. Move all the Spring dependencies out of the latter into the former.
Now you get the best of both worlds - clean, unit-testable logic, and a service that Spring can obfuscate with middleware to produce 200-line-long stacktraces after a lengthy startup.