Showing posts from September, 2017

TDD - Unit Testing Videos

01 - The Clean Code Talks -- Unit Testing
02 - Issues with Global States - Static Classes or Singletons
Strategies for testing SUT with singleton
* Instead of using the Static class directly, Extract a field and Replace all instances of the Static class with this field
* Make the field read only, Pass the static field as dependency (parameter to the constructor)
* Now in each test we can create a new instance of the mock dependency (of static class) and pass it to SUT objects constructor.

Singletons will force temporal coupling. changing the order of the lines breaks or changes the outcome.
Using Dependency Injection will force the order or dependency creation and hence avoid temporal coupling issues.
And your code functions will be honest function calls. (honest means it says what parameter it expects and what type of result it will return)

Honest -> check this name from pluralsight Vladimir Khorikov @vkhorikov or Zoran Horvat @zoranh75 video.