← Back to Upcase

Testing Factories (the Factory pattern for DI, not FactoryGirl)


(Aaron Mc Adam) #1

Hi guys, I’m trying to work out the best way to test a builder/factory (Builders::ProfilePage) that I’m using to implement Inversion of Control for a view model (ProfilePage) that’s got quite a few data needs. I’m trying to weigh up the mocking aspect of the problem against the likelihood of change of the dependencies themselves (which should be low).

Mainly I’m trying to work out a test that will provide the most value, without over-specifying the implementation, which is proving really difficult. Possibly the fact that it is a Factory means that the test should be coupled to the implementation?

The code is in this gist. Any feedback would be really awesome!