Showing posts with label hard wired dependency. Show all posts
Showing posts with label hard wired dependency. Show all posts
Monday, April 10, 2017
Mocking static method calls
Very simple example on how we can use method delegation to enable unit testing where there is a dependency to an static method call.
Labels:
dependencies,
hard wired dependency,
java,
Mock,
Mockito,
static method call,
TDD,
Unit Testing
Thursday, April 6, 2017
Dealing with Hardwired dependencies part 1 - An alternative to Dependency injection.
In this video, I show a little refactoring trick that can be used to unit test a method that has a hardwired dependency to an external system via an static method call. This is an alternative approach to dependency injection, which can be used when we are not sure about modifying the design of the class. In very large systems making design decisions such as adding another method to a constructor etc ... may have a big impact in design of both production and test harnesses. This trick can help you temporarily postpone your design decision and get you going with your unit testing.
Labels:
code smell,
hard wired dependency,
java,
Refactoring,
Unit Testing
Subscribe to:
Posts (Atom)