Monday, 4 November 2013

Unit testing mocking layer, Layered architectural pattern and Interfaces

1.       Ideally, the upper layer should depend upon the interface of lower layer, so that the upper layer can be unit tested by mocking the lower layer and provide the dummy functionality. If it is not, then we are forced to provide the PRODUCTION lower layer. If by any means this PRODUCTION lower layer is not available, or it is not possible to provide that, then we can test the upper layers. For example Payment gateways cannot be test in real. Credit card transactions cannot be tested in real. We may not be provided by a SMTP server while testing. Enterprise application has many dependencies on the outer world. While in the test we are not available with those dependencies or it is not feasible to do so. Cause update in the external Database or any other department but we do not have that Database for our application. External service is down or it is under development. Or external service is secures and it could only be used in PRODUCTION scenario. Calling service is not feasible in testing environment. Enterprise service bus cannot be used in Testing Environment and we are not available with Testing ESB. 

No comments:

Post a Comment