Better Programming

Advice for programmers.

Follow publication

Member-only story

Test-Driven Development with AI: The Right Way to Code Using Generative AI

Allen Helton
Better Programming
Published in
8 min readOct 7, 2023
Image by vectorjuice on Freepik

Unit tests are the worst. Don’t get me wrong, they are an invaluable part of any CI pipeline or automation. But man are they a pain to write.

Most developers I know, myself included, like to dive straight into code and would love to hand it over as soon as it’s functionally complete. But as those of us who have ever written something we have to support in production know, you can’t do that.

Alas, unit tests, integration tests, and end-to-end tests all need to be written to ensure that your code completely satisfies the business problem, covers all the edge cases, and is set up to maintain backward compatibility. It’s so important, in fact, that there’s an entire coding paradigm called test-driven development (TDD).

The premise behind TDD is that you write all your unit tests before you write any code. If you build your unit tests out completely making sure you cover all your business requirements, then you can test as you go. As you write the code your unit tests will stop failing, assuring you that you did what you were supposed to do.

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Allen Helton
Allen Helton

Written by Allen Helton

I am an AWS serverless hero with a strong focus on API design and standardization, event-driven architectures, and software automation.

Write a response