I'm new to TDD, but I've been reading a lot and understanding that code should be extremely modular and use dependancy injection to allow for full testability. (It also creates modularity, but that is another issue.) I've begun to program this way but it seems so verbose - injections everywhere to just get simple things done.
Then I came across AspectMock (https://github.com/Codeception/AspectMock) from this post (https://laracasts.com/forum/287-mocking-repository-model/0) where Jeffery Way describes it as a way to test Eloquent model, which usually require a repository class to test. He even made a video showing the difference: http://jeffrey-way.com/blog/2013/07/24/aspectmock-is-pretty-neat/.
To me, this seems like a complete game-changer in how we write out code. We don't have to use DI everywhere to achieve testability. We now only need to use it where we require modularity. Why has this idea not caught on and gained more traction?
This post from stackoverflow seems relevant to my question: http://stackoverflow.com/questions/2407540/what-are-the-downsides-to-using-dependency-injection
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community