Unit tests are one of those things that evolve over time. When we talk about test coverage, anyone that thinks they have full coverage is kidding themselves, but it’s not uncommon for my workflows to just build some stuff and go back and fill in the unit tests before I bring in a second person. And yet… we know we need to do them. Sometimes I’ve gotten help with this specific part of projects from sites like Upwork.
There’s been a lot of talk about AI eating the world, so I thought I’d see how much of this kind of thing AI could get us for free. Let’s start with a simple little Google Cloud Function written in Go that converts some ascii to binary (which I oh so creatively called ascii_to_binary.go). Getting this exactly right was simple once I got there. The request was:
create a unit test for this script:
Then a shift carriage-return (or two) and paste the script, which looks as follows.
The output then has a “copy to clipboard” option. Click that, touch a file, paste it in, name with .go at the end, and then the go binary can be run normally:
go test -v ascii_to_binary.go
Or it could be run with the test option (and a verbose -v flag):
go test -v ascii_to_binary.go
This examples uses go; but I’ve now tested this with Node.js, Go, Python, and Swift. I’ve also been experimenting with using Bard and other platforms to do tasks in swagger, postman, && Google Cloud Functions/Lambdas. Overall, I’m finding plenty of syntax errors when trying to generate raw code, which tend to take longer than writing it myself, but for a lot of the other adjacent tasks, I’m digging the productivity gains of these kinds of platforms.