Source: matthiasnoback.nl

Don't test constructors
Posted on May31st2021 by Matthias Noback@ediar asked me on Twitter if I still think a constructor should not be tested. It depends on the type of object you're working with, so I think it'll be useful to elaborate here. Would you test the constructor of a service that just gets some dependencies injected?

Yes, but in very specific ways, none of which is this one: ("Why do we need to know the user's gender?"

So then you want to write this test: At this point, the test "forces" you to keep track of the is-suspended state somehow, and of course, you'd do that with an object property.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners