Menu

Post image 1
Post image 2
1 / 2
0

Your Go Golden Tests Don't Need to Regenerate Everything

DEV Community·Bala Paranj·21 days ago
#a3UHA0s9
#why#go#testing#golden#test#fullscreen
Reading 0:00
15s threshold

A practical pattern for targeted golden file regeneration in Go projects — from minutes to 0.27 seconds. I have 5,810 golden files in my project. Every time I changed one test, I was regenerating all of them. It took minutes. Now it takes 0.27 seconds. The fix was just organizing the regeneration path so you could aim it at one file instead of firing at everything. The problem with regenerate everything Golden tests are great. You capture known-good output, save it to a file, and compare against it on every run. When the output changes intentionally, you regenerate the golden file. Most Go projects start with a simple approach: a Makefile target that regenerates all golden files at once. make regenerate-goldens Enter fullscreen mode Exit fullscreen mode This works when you have 20 golden files. When you have 5,810, it doesn't. You change one test, you wait for the tool to process every fixture directory, and most of the time nothing else changed. You're wasting time to update one file.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More