Write tests using AI
Nov 12, 2022
More specifically, using GitHub Copilot.
Unit tests are very useful to have. But writing them is so boring. And even if you like writing tests, you probably feel the tediousness too. Writing multiple sub-cases for each method or function and then repeating the similar patterns for other methods.
Instead, automate it through some AI. Here’s an example of copilot being extremely helpful:
The gray bit is copilot’s suggestion.
What is being tested is not so important. But the fact that I did not have to write that volume of code (which would definitely also involve looking up biggest and smallest float64 numbers on the internet) is amazing! Much respect for this sort of AI. Take my money.
But not my job please :‘(
Copilot also does a good job of guessing my actual business logic code. It gets it wrong only sometimes. But I like to not take much help from it, especially on hobby projects. What would be the point if you are not even enjoying the craft of writing code.
Anyway, these things will eventually become part of developer workflows just like we have IDEs or static analysis tools. I don’t mind using AI if it saves me some typing. Writing the code is only a part of the process of building software. You still have to tell the computer what you want it to do, same as always.
Until that gets automated too. Looking forward to not seeing that future anytime soon.
But even if it does happen in my lifetime, I bet people will still write code by hand. Just like how some of the old trades, where skilled human hands were required (clothing, smithing, etc.), still exist today. Even after industrial revolution. They have just become niche. Maybe handmade luxury software will be a thing too!