oliverdavies.uk/content/node.80c27b8b-ebb6-486e-9fb8-a4d29ade396c.json

100 lines
4.7 KiB
JSON
Raw Normal View History

2025-04-16 23:34:31 +01:00
{
"uuid": [
{
2025-05-11 09:40:11 +01:00
"value": "80c27b8b-ebb6-486e-9fb8-a4d29ade396c"
2025-04-16 23:34:31 +01:00
}
],
"langcode": [
{
"value": "en"
}
],
"type": [
{
"target_id": "daily_email",
"target_type": "node_type",
"target_uuid": "8bde1f2f-eef9-4f2d-ae9c-96921f8193d7"
}
],
"revision_timestamp": [
{
2025-05-11 09:40:11 +01:00
"value": "2025-05-11T09:00:28+00:00"
2025-04-16 23:34:31 +01: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": "Writing good test names\n"
}
],
"created": [
{
"value": "2023-11-18T00:00:00+00:00"
}
],
"changed": [
{
2025-05-11 09:40:11 +01:00
"value": "2025-05-11T09:00:28+00:00"
2025-04-16 23:34:31 +01:00
}
],
"promote": [
{
"value": false
}
],
"sticky": [
{
"value": false
}
],
"default_langcode": [
{
"value": true
}
],
"revision_translation_affected": [
{
"value": true
}
],
"path": [
{
"alias": "\/daily\/2023\/11\/18\/writing-good-test-names",
2025-04-29 14:30:51 +01:00
"langcode": "en"
2025-04-16 23:34:31 +01:00
}
],
"body": [
{
"value": "\n <p>In PHPUnit, there are different ways to write test methods.<\/p>\n\n<p>The standard way is to use camel-case method names with a <code>test<\/code> prefix, for example:<\/p>\n\n<pre><code class=\"language-php\">public function testTheProjectNameShouldBeAString(): void\n{\n \/\/ ...\n}\n<\/code><\/pre>\n\n<p>Another popular way, particularly in some frameworks, is to use snake-case method names:<\/p>\n\n<pre><code class=\"language-php\">\/** @test *\/\npublic function the_project_name_should_be_a_string(): void\n{\n \/\/ ...\n}\n<\/code><\/pre>\n\n<p>This may be more readable but only works if the <code>@test<\/code> annotation is present.<\/p>\n\n<p>What if you need to add another annotation, such as <code>@dataProvider<\/code> to the test? Do you do multi-line docblocks everywhere, or mix and match single and multiple line docblocks depending on the test?<\/p>\n\n<h2 id=\"here%27s-the-thing\">Here's the thing<\/h2>\n\n<p>My preference switches between both ways of writing test methods.<\/p>\n\n<p>But, whichever way I write it, I write descriptive method names that explain what the test does - even if it means having a long method name.<\/p>\n\n<p>I avoid short and generic names like <code>testUpdate()<\/code>.<\/p>\n\n<p>People should be able to read the test name and understand what it does and what it's testing.<\/p>\n\n ",
"format": "full_html",
"processed": "\n <p>In PHPUnit, there are different ways to write test methods.<\/p>\n\n<p>The standard way is to use camel-case method names with a <code>test<\/code> prefix, for example:<\/p>\n\n<pre><code class=\"language-php\">public function testTheProjectNameShouldBeAString(): void\n{\n \/\/ ...\n}\n<\/code><\/pre>\n\n<p>Another popular way, particularly in some frameworks, is to use snake-case method names:<\/p>\n\n<pre><code class=\"language-php\">\/** @test *\/\npublic function the_project_name_should_be_a_string(): void\n{\n \/\/ ...\n}\n<\/code><\/pre>\n\n<p>This may be more readable but only works if the <code>@test<\/code> annotation is present.<\/p>\n\n<p>What if you need to add another annotation, such as <code>@dataProvider<\/code> to the test? Do you do multi-line docblocks everywhere, or mix and match single and multiple line docblocks depending on the test?<\/p>\n\n<h2 id=\"here%27s-the-thing\">Here's the thing<\/h2>\n\n<p>My preference switches between both ways of writing test methods.<\/p>\n\n<p>But, whichever way I write it, I write descriptive method names that explain what the test does - even if it means having a long method name.<\/p>\n\n<p>I avoid short and generic names like <code>testUpdate()<\/code>.<\/p>\n\n<p>People should be able to read the test name and understand what it does and what it's testing.<\/p>\n\n ",
"summary": null
}
],
"feeds_item": [
{
2025-05-14 00:09:16 +01:00
"imported": "1970-01-01T00:33:45+00:00",
2025-04-16 23:34:31 +01:00
"guid": null,
"hash": "05bef1d24f084368e652eb41e2831725",
"target_type": "feeds_feed",
"target_uuid": "90c85284-7ca8-4074-9178-97ff8384fe76"
}
]
}