Generating tests (semi) automatically
This is part of a series on Wicked Fast Testing, a testing style that represents tests as JSON data. Check out Part 1 for a quick introduction.
Generating tests semi-automatically is important because manually typing out test cases is a drag on coding speed, even with vim. Unfortunately generating useful tests fully automatically from code is a significantly difficult problem.
In this post, we’ll show how with a few lines of python, we can generate dozens or hundreds of tests.
What is test generation?
Test generation is using a computer to write tests. It’s not enough to generate the raw data or the test case, but the entire test. Since Wicked Fast Testing supports snapshot testing, we already have a solution to generating the expected test values. Therefore the remaining open problem is generating the test case as well as formatting into a test. Formatting a test case into a test is easy with Wicked Fast Testing because its tests are a json array of well structured json objects.