I've been working with a Large Language Model (LLM) for my indie projects, and I've realized that having solid tests in place is crucial. Sometimes, the LLM introduces changes that inadvertently break parts of my code. As a newbie to testing, I'm looking for some expert-level tips on how to write effective tests for smaller applications. What are some common pitfalls that less experienced developers stumble into? Are there any practical insights that might go against standard practices but work better in real-world scenarios?
3 Answers
The best advice? Write the tests yourself! If you're going to vibe code with your LLM, definitely make sure you have tests to back up what you want your code to accomplish. They act like a contract for your app's behavior.
For unit tests, focus on three things: ensure it works, ensure it fails gracefully, and check some edge cases. As for end-to-end tests, try to have someone who knows nothing about the implementation do the testing. This way, you can adapt their approach to develop a solid end-to-end strategy.
Honestly, I’d suggest writing your tests manually rather than relying on the LLM for that. In my experience, when the LLM tries to draft unit tests, it gets the essence of what a method is supposed to do all wrong. But here's an idea: why not flip the script and let the LLM help after you write the tests? You could draft the tests first, then use them as a guide for the LLM to write the implementation. It's not perfect for complex parts but ensures you’ve got valuable tests from the get-go, rather than treating them as an afterthought.
Related Questions
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically
[Centos] Delete All Files And Folders That Contain a String