DEV Community

Cover image for Don't use AI for testing
Franco
Franco

Posted on

Don't use AI for testing

Let me give you a piece of advice: don’t use AI (Copilot, GPT, etc.) for testing. Don’t get me wrong—what I mean by this is: use AI for testing in moderation, but please, don’t delegate all your testing responsibilities to these tools.


Why?

Okay, I admit it—I’m a big fan of testing. I believe that, at an enterprise level, testing = code = documentation in terms of importance. Without proper tests, it’s incredibly difficult to deploy correct features to production that meet the requirements. It’s also challenging to maintain these features in the long run.

Whether you engage in defensive testing (writing tests after the code) or offensive testing (writing tests before the code, such as using TDD), the mere act of writing tests forces you to think critically about the code. It compels you to review the main cases and edge cases, giving you an extra opportunity to ensure the code is as robust as possible before it reaches staging or production.


Looking Beyond

If we underestimate testing and treat it as a "necessary evil" while working on a ticket, we risk falling into the trap of a typical Copilot prompt: “Write a unit test for this class.” Worse yet, we might simply copy-paste the result without even reviewing it. This can lead to weak tests that pass only because of superficial assertions like “true to be true” or similar.

While this might seem like a time-saver at first, avoiding the effort of writing tests from scratch, the reality is that in the short, medium, and long term, this approach will bring us significant headaches. The reason? The test won’t be solid enough to prove that the code meets its requirements and is free of critical bugs (not all bugs—since it’s impossible to prove the absence of bugs, only their presence).

Beyond Code

Beyond the code itself, this approach can harm us as developers. We risk losing reputation and credibility regarding the quality of our work. At the same time, we lose the chance to learn valuable skills related to testing, which I find both beautiful (subjectively speaking) and crucial.


It’s Like Everything Else

What I’m saying about testing applies to many other concepts in software development. It’s essential to understand that AI is just another tool in the developer’s arsenal. When used properly, it can make a significant difference—when used properly. It cannot be used blindly for everything, just as we can’t dismiss it entirely and refuse to use it at all.

As always, the challenge for software developers is to recognize this and balance the use of tools according to the context where they’re solving a problem. After all, a software developer’s job is to solve problems strategically, using the right tools to achieve that goal.


Conclusion

This perspective is based on my experience as a software developer. Of course, it’s far from being the ultimate truth and should be taken as one more point of view. I encourage you to share your thoughts in the comments so we can spark a discussion within the community and learn even more from each other.

Happy coding! 🤓

Top comments (0)