How to mock the java URL class with mockito

How to mock the java URL class with mockito

Unit testing classes that use java’s URL class The java URL class java.net.URL models a remote resource location, and provides methods to retrieve resource content.  Common use cases are to retrieve resources over HTTP/S, but it can also be used to retrieve files or classpath resources.  Typically, the URL instance is constructed within your class method: To […]

To Unit Test or Integration Test

To Unit Test or Integration Test

To Unit Test or Integration Test … that is the question. And that is the subject of this post. I will be exploring whether it is better to write Unit Tests or Integration Tests, or whether there is a sweet spot in the middle ground somewhere. Striking the right balance It’s hard to get the balance right. […]

Unit testing and expected exceptions

Unit testing and expected exceptions

Testing for expected exceptions Unit testing – we’re all well versed at it by now, we know why we do it and we know how to do it. It’s baked into our development lifecycle and we do it well. Right? … This post looks at the case where we are expecting a given test scenario […]