RSSAmplifier

On the Web on joe blubaugh · Jun 20, 2023

Don't use mocks

0
Sign in to vote or save

This page cannot be shown here. You can still read it on the original site — the toolbar below keeps your place in the directory.

Writing good unit tests is made much easier by dependency injection . This lets you separate your code’s behavior from that of your dependencies: type MyType struct { dep1 DependencyOne dep2 DependencyTwo } func GoodConstructor ( dep1 DependencyOne , dep2 DependencyTwo ) * MyType { return & MyType { dep1 : dep1 , dep2 : dep2 , } } func BadConstructor () * MyType { return & MyType { dep1 :…

Read on /blog/2023_06_mocks/

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.