Skip to content

jdevora/test_static_methods

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

When a class gets a collaborator from a static factory and it is not feasible to inject the collaborator in normal circumstances you could uses a few different techniques to test or mock the collaborator:

Add a setter to the Factory, this could be called before running a test. This way we could inject a mocked collaborator

Add custom constructor that is only called at test time for inject a mock collaborator

Add a custom Collaborator setter, this setter is never called at run time because the collaborator is created the "normal way" but at test time can be used to inject a mock collaborator.

About

A few options to test a private colaborator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages