Thursday, January 10, 2013
JustMock is a great tool for abstracting dependencies in unit tests, and the new automocking feature makes it even faster to develop unit tests. Another great feature in JustMock and JustMock Lite is the capability to assert the behavior of your system under test.
Traditional TDD (Test Driven Testing) unit testing typically tests for state. Did the user get logged in? Did the user’s shopping cart get loaded? Important tests, of course. But that only tests the end result of the method. If the user does NOT successfully login, and the cart is not reloaded, is that because the call to the repository was never called? Or because some error happened that didn’t reload the cart in this particular use case? The state of the application is correct, but is that because it executed the expected behavior, or because we got lucky?