It’s my birthday today, so what is better than to write a story about my agony.
I write a lot of code specifically in Flutter projects. The typical structure includes a lib folder and a test folder with matching folder structures.
The problem
The problem with keeping test files in sync…
- You have a lib/ file with the following path:
lib/src/utils/strings.dart
and a matching test file intest/src/utils/strings_test.dart
. - You now move the lib/ file from
lib/src/utils/strings.dart
tolib/src/strings.dart
. - You now have a test file that is not matching the lib file structure anymore.
The solution
I made a good old script in Dart that would sync the structure of the lib
folder to the test
folder.
Open source, use it or don’t. I don’t care. I just want you to know that I hate test files, but sometimes I don’t.