oliverdavies.uk/content/node.a699f864-3453-4f53-92d5-b394bfaebef7.json
2025-05-11 20:02:14 +01:00

100 lines
No EOL
7.4 KiB
JSON

{
"uuid": [
{
"value": "a699f864-3453-4f53-92d5-b394bfaebef7"
}
],
"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:32+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 not to break 36,000 websites\n"
}
],
"created": [
{
"value": "2023-09-16T00:00:00+00:00"
}
],
"changed": [
{
"value": "2025-05-11T09:00:32+00:00"
}
],
"promote": [
{
"value": false
}
],
"sticky": [
{
"value": false
}
],
"default_langcode": [
{
"value": true
}
],
"revision_translation_affected": [
{
"value": true
}
],
"path": [
{
"alias": "\/daily\/2023\/09\/16\/how-not-to-break-36-000-websites",
"langcode": "en"
}
],
"body": [
{
"value": "\n <p>I've maintained the Override Node Options module for Drupal since early 2012.<\/p>\n\n<p>I've maintained the Drupal 7 version and written new versions for Drupal 8 onwards.<\/p>\n\n<p>At the time of writing, the module is used on at least 36,244 active Drupal websites.<\/p>\n\n<p>I don't want to break 36,000 websites, and automated testing is my way of avoiding that.<\/p>\n\n<p>I have three examples of how automated testing helped me when working on this module.<\/p>\n\n<h2 id=\"upgrading-to-drupal-8\">Upgrading to Drupal 8<\/h2>\n\n<p>When writing the initial Drupal 8 version of the module, as I started re-writing a feature, the first thing I did was recreate the tests from the Drupal 7 version.<\/p>\n\n<p>Then, I followed a test-driven development approach to get the test passing using the Drupal 7 code for reference.<\/p>\n\n<p>When the whole test suite was in place and passing, I knew there was feature parity between the two versions.<\/p>\n\n<h2 id=\"resolving-a-large-merge-conflict\">Resolving a large merge conflict<\/h2>\n\n<p>I was reviewing a feature request that had been open for some time, which included a large patch file with the code changes to implement it.<\/p>\n\n<p>However, the patch no longer applied to the code, which caused various merge conflicts.<\/p>\n\n<p>There were no additional tests within the patch, but I was able to use the existing tests to ensure the original functionality worked once the merge conflicts were resolved and there were no regressions caused by committing the patch.<\/p>\n\n<p>I did later add tests for the new functionality, but without the original test suite, I would have likely not have accepted the patch and not committed the feature.<\/p>\n\n<h2 id=\"refactoring-the-code\">Refactoring the code<\/h2>\n\n<p>A few years ago, a colleague and I wanted to refactor the module code to make it more maintainable and easier to work on.<\/p>\n\n<p>Then, the module was used on around 30,000 websites, so this could have been risky.<\/p>\n\n<p>However, we had the test suite to ensure the functionality still worked and that our refactors were successful.<\/p>\n\n<p>If we broke something and introduced a regression, a test would fail, and we could fix it.<\/p>\n\n<p>Following the release containing the refactored code, there were no reported issues or regressions from the community.<\/p>\n\n<h2 id=\"here%27s-the-thing\">Here's the thing<\/h2>\n\n<p>Automated testing is about providing confidence.<\/p>\n\n<p>Confidence the software works as expected and is releasable, either to clients for custom software or consumers of open-source software.<\/p>\n\n<p>With a passing test suite, you can add and change code with confidence and without worrying about breaking it.<\/p>\n\n ",
"format": "full_html",
"processed": "\n <p>I've maintained the Override Node Options module for Drupal since early 2012.<\/p>\n\n<p>I've maintained the Drupal 7 version and written new versions for Drupal 8 onwards.<\/p>\n\n<p>At the time of writing, the module is used on at least 36,244 active Drupal websites.<\/p>\n\n<p>I don't want to break 36,000 websites, and automated testing is my way of avoiding that.<\/p>\n\n<p>I have three examples of how automated testing helped me when working on this module.<\/p>\n\n<h2 id=\"upgrading-to-drupal-8\">Upgrading to Drupal 8<\/h2>\n\n<p>When writing the initial Drupal 8 version of the module, as I started re-writing a feature, the first thing I did was recreate the tests from the Drupal 7 version.<\/p>\n\n<p>Then, I followed a test-driven development approach to get the test passing using the Drupal 7 code for reference.<\/p>\n\n<p>When the whole test suite was in place and passing, I knew there was feature parity between the two versions.<\/p>\n\n<h2 id=\"resolving-a-large-merge-conflict\">Resolving a large merge conflict<\/h2>\n\n<p>I was reviewing a feature request that had been open for some time, which included a large patch file with the code changes to implement it.<\/p>\n\n<p>However, the patch no longer applied to the code, which caused various merge conflicts.<\/p>\n\n<p>There were no additional tests within the patch, but I was able to use the existing tests to ensure the original functionality worked once the merge conflicts were resolved and there were no regressions caused by committing the patch.<\/p>\n\n<p>I did later add tests for the new functionality, but without the original test suite, I would have likely not have accepted the patch and not committed the feature.<\/p>\n\n<h2 id=\"refactoring-the-code\">Refactoring the code<\/h2>\n\n<p>A few years ago, a colleague and I wanted to refactor the module code to make it more maintainable and easier to work on.<\/p>\n\n<p>Then, the module was used on around 30,000 websites, so this could have been risky.<\/p>\n\n<p>However, we had the test suite to ensure the functionality still worked and that our refactors were successful.<\/p>\n\n<p>If we broke something and introduced a regression, a test would fail, and we could fix it.<\/p>\n\n<p>Following the release containing the refactored code, there were no reported issues or regressions from the community.<\/p>\n\n<h2 id=\"here%27s-the-thing\">Here's the thing<\/h2>\n\n<p>Automated testing is about providing confidence.<\/p>\n\n<p>Confidence the software works as expected and is releasable, either to clients for custom software or consumers of open-source software.<\/p>\n\n<p>With a passing test suite, you can add and change code with confidence and without worrying about breaking it.<\/p>\n\n ",
"summary": null
}
],
"feeds_item": [
{
"imported": "2025-05-11T09:00:32+00:00",
"guid": null,
"hash": "29be860248a883db12a44b89149e1392",
"target_type": "feeds_feed",
"target_uuid": "90c85284-7ca8-4074-9178-97ff8384fe76"
}
]
}