uuid: - value: 18cac962-eefd-4506-8efd-cd584f027369 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:30+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: | How to test code you didn't write created: - value: '2023-10-24T00:00:00+00:00' changed: - value: '2025-05-11T09:00:30+00:00' promote: - value: false sticky: - value: false default_langcode: - value: true revision_translation_affected: - value: true path: - alias: /daily/2023/10/24/how-to-test-code-you-didnt-write langcode: en body: - value: |

I was also asked at DrupalCon how you write tests for code you didn't write and how you cover all of the use cases and scenarios.

This is tricky. If you didn't write the code, how can you know all the scenarios you need to test?

Presumably, there is some documentation, Jira tickets, user stories or acceptance criteria from when the code was written that will help you with this.

Decide the most critical functionality to be tested and focus on that, as that will provide the most value.

I'd start with functional tests and test for high-level outcomes, such as whether a page loads, returns the correct status code, and contains the expected text.

Then, iteratively add more tests for other scenarios. Once you have the first one written, this should be easier as you already have the setup steps, such as which modules must be enabled and what configuration needs to be installed.

One test is better than none.

If you need to add any new features or fixes, ensure they have their own tests to keep a consistent level of coverage.

Even with a simple module, you're unlikely to be able to identify all of the scenarios, write all the tests in one go, and have everything covered.

Start with the most important test first and continue to add more iteratively.

format: full_html processed: |

I was also asked at DrupalCon how you write tests for code you didn't write and how you cover all of the use cases and scenarios.

This is tricky. If you didn't write the code, how can you know all the scenarios you need to test?

Presumably, there is some documentation, Jira tickets, user stories or acceptance criteria from when the code was written that will help you with this.

Decide the most critical functionality to be tested and focus on that, as that will provide the most value.

I'd start with functional tests and test for high-level outcomes, such as whether a page loads, returns the correct status code, and contains the expected text.

Then, iteratively add more tests for other scenarios. Once you have the first one written, this should be easier as you already have the setup steps, such as which modules must be enabled and what configuration needs to be installed.

One test is better than none.

If you need to add any new features or fixes, ensure they have their own tests to keep a consistent level of coverage.

Even with a simple module, you're unlikely to be able to identify all of the scenarios, write all the tests in one go, and have everything covered.

Start with the most important test first and continue to add more iteratively.

summary: null field_daily_email_cta: { }