Many of us know that testing our code is important. The adoption of unit testing by many software application developers as a normal course of business has dramatically improved the quality of applications. Mobile software, especially, has benefited from the requirement for most software to include and constantly run a suite of unit tests.
For database software, I find relatively few organizations formally test their database software. A few people have adopted tSQLt or the Microsoft Unit Testing Framework, but most don't bother. In fact, many queries that are embedded in application code, or built by ORMs, aren't tested beyond a developer looking at the results from their own (limited set of) test data. That often doesn't catch errors until someone in production runs their application against a larger set of data.
What might be worse is that refactoring those queries might produce different results that aren't tested against regressions.
In this new age of AI-assisted coding, testing is becoming more important. Grant wrote an interesting post on LinkedIn that discusses your job changing in the age of AI. You need to have more testing that ensures you validate code that the AI produces, which is going to be more important as the amount of code grows. AI will produce lots more code, and potentially, lots more poor code. We will need to ensure that the generated code has some validation that the results are what we expect.
Unit tests help here, and while I know these can be tedious to write and maintain, this is a great use for AI assistance. Generating unit tests, with default data based on data in current tables, is something AI agents can do well. They can also use these to verify functionality as code is generated and refactored. Of course, humans still need to be in the loop as there are plenty of reports where AI Agents write tests that return success without actually testing code. You need to validate the tests, and ensure your AI uses those tests to validate its work.
Something humans have done as well.
AI is an amazing tool, but like an intelligent, over-eager, junior developer, it needs clear communication and strong guidance.
And a little review of its work.