DEV Community

Discussion on: When PHP Framework Sucks Series: Business logic free Controllers

Collapse
 
damnjan profile image
Damnjan Jovanovic

Hi Joey, thank you very much for putting the effort in so descriptive comment!
First I have to say that I read your comment a couple of times and I agree with some points 100%.

  • The first point which you mention is that I make mock way to strict, that's what I going to change right now. Thanks for this comment. There is also another colleague of mine who recently pointed to me a couple of places when I did the same lock-to-implementation. So it is definitely something I have to improve :)
  • I also agree that mock code took a great number of line in the test, but I have an excuse for that since I make it for readability, so the one who read this article get it immediately.

When it comes to the improvement proposition you mentioned I personally strongly disagree with point one (Consider simply not having that test. Is it really useful?). I hear that opinion along with point two (Make it another type of test, such as an integration test (you can use sqlite in memory, etc).) from time to time, but I think it is not the way we should go. I can imagine that you also think that chasing 100% unit test coverage is the right goal, and that's the point where I usually disagree with my colleagues who have a similar approach like yours. In my opinion, the unit test should have 100% coverage, and one test class per one production class, integration, and functional tests should also take place in the repo but not as a replacement for unit tests.

Just to be clear, I don't think my opinion and approach is necessary right in the point where we disagree, I just found it useful and beneficial from my experience.

I'm also curious, what is an argument in your opinion, for not having a unit test for some class?
Cheers!