I have a Model method that makes use of several methods from other classes (Some from third party libraries, some from helper classes, etc.). When unit testing this method, I am mocking every method called in that original method. Everything works fine.
However, the test method is too long to my liking (40 lines!). The actual testing code is only 2 lines, the rest is preparing mock methods and instructing Laravel to use the mocks in place of the real methods.
Is this normal? In many places I saw people recommending unit tests to be small, but having mocks in there makes it impossible to make it small. How would you proceed?
if you are mockng these things in other methods then maybe split them out to another function.. & use this test class's variables..
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community