Don't use AI to write your automated tests

In yesterday's email, I mentioned some of the recent issues I've seen from AI tools.

I'm wary of any code generated by AI, as I've often found it to be incorrect.

If you rely on AI-generated code, I'd be especially wary if it also generates the automated tests.

Automated tests verify your application works as expected, so you need to ensure they are testing the correct things and the logic is correct.

Can you make a test purposely fail by changing some logic within the test or implementation code?

Is it clear what each test is doing?

Are the tests running the implementation code or just testing mocks or running meaningless assertions like self::assertTrue(TRUE)?

Writing tests is about building confidence, which you can't do if you don't know what your tests are testing or how.

- Oliver

Was this interesting?

Sign up here and get more like this delivered straight to your inbox every day.

About me

Picture of Oliver

I'm an Acquia-certified Drupal Triple Expert with 17 years of experience, an open-source software maintainer and Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.