Friday, August 31, 2018

Avoiding Common Hurdles in Unit Testing

Why do developers skip writing tests for some code? Perhaps because it relies on the file system or an external API. Perhaps because we think it's too difficult, or a test account to an external API is not guaranteed to be available. Perhaps it's because an external API may not be accessible from the CI environment due to VPN restrictions. Perhaps mocking in your test suite has become so complicated that maintaining the mocks is not yielding enough return for the investment of time. This can happen because mocking is too tightly coupled to the code being tested.

Sometimes testing every branch seems like an insurmountable obstacle. Knowing how to easily test error conditions makes increasing branch coverage a lot easier.



from DZone.com Feed https://ift.tt/2wrKbJs

No comments:

Post a Comment