oliverdavies.uk/source/_daily_emails/2023-12-16.md

29 lines
1.1 KiB
Markdown
Raw Permalink Normal View History

2024-01-03 20:00:00 +00:00
---
title: >
2024-09-08 22:09:54 +00:00
Adding snapshot tests to Build Configs
2024-01-03 20:00:00 +00:00
pubDate: 2023-12-16
permalink: >-
daily/2023/12/16/adding-snapshot-tests-to-build-configs
2024-01-03 20:00:00 +00:00
tags:
2024-09-08 22:09:54 +00:00
- software-development
- php
- symfony
- build-configs
- automated-testing
- test-driven-development
2024-01-03 20:00:00 +00:00
---
This week, I've started to add snapshot tests to the [Build Configs project][build configs].
I had unit tests for the DTO validation to ensure the configuration was correct, but the main thing I wanted to test was I could run it for a given configuration file and get the expected files and contents to be generated.
With snapshot tests, I generate the files for each configuration and compare them to a set that I know to be correct.
If the files match, the tests pass, but, if they don't - such as a bug in the code, the tests will fail.
This is the level that I want to be testing this project and that provides the most value.
If a snapshot test fails, I can try to replicate the underlying issue in a unit test whilst also fixing the snapshot test.
[build configs]: https://www.oliverdavies.dev/build-configs