3 ms·
If an exception breaks business logic, then you can test the code by testing business logic. How do null pointer exceptions arise? Inconsistent data: you have
by dgb23 3y ago
If an exception breaks business logic, then you can test the code by testing business logic.
How do null pointer exceptions arise?
Inconsistent data: you have code paths that implicitly assume invariants. Trivial cases like “this field is not provided” and more complex ones like “these fields have a specific relationship”.
You can often move those assumptions into the data structure in any language.
Then your tests become a matter of generating and transforming data from a holistic perspective instead of micromanaging individual code paths.