This can be a big debate. Developers testing their own code – what will be the testing output? All happy endings! Yes, the person who develops the code generally sees only happy paths of the product and don't want to go into many details.
The main concern of developer testing is – misunderstanding of requirements. If requirements are misunderstood by developer then no matter at what depth developer test the application, he will never find the error. The first place where the bug gets introduced will remain till the end, a developer will see it as functionality.
Optimistic developers – Yes, I wrote the code and I am confident it's working properly. No need to test this path, no need to test that path, as I know it's working properly. And right here developers skip the bugs.
Developer vs Tester: Developer always wants to see his code working properly. So he will test it to check if it's working correctly. But you know why tester will test the application? To make it fail in any way, and tester surely will test how an application is not working correctly. This is the main difference in developer testing and tester testing.
Should developers test their own work?
This is all applicable to a developer who is a good tester! But most of the developers consider testing as a painful job, even they know the system well, due to their negligence they tend to skip many testing paths, as it's a very painful experience for them. If developers find any errors in their code in unit testing then it's comparatively easier to fix, as the code is fresh to them, rather than getting the bug from testers after two-three days. But this only possible if the developer is interested in doing that much testing.
It's testers responsibility to make sure each and every path is tested or not. Testers should ideally give importance to all small possible details to verify the application is not breaking anywhere.
Developers, please don't review your own code. Generally, you will overlook the issues in your code. So give it to others for review.
Everyone is having specialization in particular subject. Developers generally think how to develop the application on the other hand testers think how the end user is going to use the application.
So, in short, there is no problem if developers are doing the basic unit testing and basic verification testing. Developers can test few exceptional conditions they know are critical and should not be missed. But there are some great testers out there. Through the build to test team. Don't waste your time as well. For the success of any project, there should be independent testing team validating your applications. After all, it's our (testers) responsibility to make the ‘baby’ smarter!!
What did you say?