Test Dart code generators built on source_gen by annotating test files
open sourceMITfree
source_gen_test makes it easy to test Dart code generators derived from package:source_gen. You annotate classes in a test library with the output a generator should produce (@ShouldGenerate), the error it should throw (@ShouldThrow) or a golden file to compare against (@ShouldGenerateFile), each for one or more generator configurations. verifyGeneratorBatch runs large matrices of declaration permutations against a generator in one shared analyzer context, and the package bundles an agent skill for stress-testing generators that way.
Problems it solves
- write tests for my Dart source_gen code generator
- check a Dart generator's output against a golden file
- test that my code generator throws the right error for bad input
Features
- @ShouldGenerate and @ShouldThrow annotations for generator tests
- golden-file tests with @ShouldGenerateFile
- verifyGeneratorBatch for combinatorial generator testing
- bundled source-gen-test-fuzz agent skill
Alternatives
The same job
These do what source_gen_test does.
- build_verify Test that generated Dart code is up to date
