Writing testable code
The question asks about your experience writing code with unit tests in mind and the philosophy you took from it. Give me the principles you hold to as concrete code-level habits.
The question asks about your experience writing code with unit tests in mind and the philosophy you took from it. Give me the principles you hold to as concrete code-level habits.
Take dependencies through the initializer and don't call singletons directly. Pull decision logic into pure functions from input to output and push side effects to the edges. Inject time, UUID, and randomness, and express state as a value type so it's comparable. Treat "this is hard to test" as a design signal and change the code.
TestingShort answerBasics
This screen leans heavily on an API response. How would you change the code so you can…
#testability #dependency-injection
TestingShort answerAdvanced
One item the architecture round scores is "can you add unit tests without a big…
#testability #dependency-injection
ArchitectureShort answerBasics
Dependency Injection and the Dependency Inversion Principle have similar names. What's…
#testability #dependency-injection
ArchitectureMultiple choiceBasics
In a codebase where a singleton like AnalyticsManager.shared is referenced directly all…
#testability #dependency-injection