uuid: - value: e652f53d-9472-4ce0-a70b-79f0dbaa9d1a langcode: - value: en type: - target_id: daily_email target_type: node_type target_uuid: 8bde1f2f-eef9-4f2d-ae9c-96921f8193d7 revision_timestamp: - value: '2025-05-11T09:00:51+00:00' revision_uid: - target_type: user target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849 revision_log: { } status: - value: true uid: - target_type: user target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849 title: - value: | Are missing tests a blocker to refactoring? created: - value: '2022-11-19T00:00:00+00:00' changed: - value: '2025-05-11T09:00:51+00:00' promote: - value: false sticky: - value: false default_langcode: - value: true revision_translation_affected: - value: true path: - alias: /daily/2022/11/19/are-missing-tests-a-blocker-to-refactoring langcode: en body: - value: |
Is having automated tests a prerequisite for refactoring a piece of code?
Without passing tests for that code, any changes made could introduce a regression, and bugs can be accidentally introduced.
When refactoring with tests, you run them before making any changes to ensure they pass. The tests are rerun after every change to ensure that they still pass and that the change didn't introduce a regression that caused the test to fail. If a test fails, the change is reverted and re-attempted.
If I need to refactor some code without tests, the first thing that I'll do is add some initial tests before the main work.
Whilst nothing is stopping me from refactoring without the tests, the risk isn't something that I'd want to take on, and I'd much prefer to have some tests in place - just in case!
format: full_html processed: |Is having automated tests a prerequisite for refactoring a piece of code?
Without passing tests for that code, any changes made could introduce a regression, and bugs can be accidentally introduced.
When refactoring with tests, you run them before making any changes to ensure they pass. The tests are rerun after every change to ensure that they still pass and that the change didn't introduce a regression that caused the test to fail. If a test fails, the change is reverted and re-attempted.
If I need to refactor some code without tests, the first thing that I'll do is add some initial tests before the main work.
Whilst nothing is stopping me from refactoring without the tests, the risk isn't something that I'd want to take on, and I'd much prefer to have some tests in place - just in case!
summary: null field_daily_email_cta: { }