79 lines
4.2 KiB
YAML
79 lines
4.2 KiB
YAML
uuid:
|
|
- value: 5a77f50e-a593-4a7f-b2b2-1a39114e9668
|
|
langcode:
|
|
- value: en
|
|
type:
|
|
- target_id: daily_email
|
|
target_type: node_type
|
|
target_uuid: 8bde1f2f-eef9-4f2d-ae9c-96921f8193d7
|
|
revision_timestamp:
|
|
- value: '2025-07-15T20:33: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: 'Drupal Test Traits is not a replacement for traditional tests'
|
|
created:
|
|
- value: '2025-07-13T20:31:38+00:00'
|
|
changed:
|
|
- value: '2025-07-15T20:33:32+00:00'
|
|
promote:
|
|
- value: false
|
|
sticky:
|
|
- value: false
|
|
default_langcode:
|
|
- value: true
|
|
revision_translation_affected:
|
|
- value: true
|
|
path:
|
|
- alias: /daily/2025/07/13/drupal-test-traits-not-replacement-traditional-tests
|
|
langcode: en
|
|
body:
|
|
- value: |-
|
|
I've recently been looking into [the Drupal Test Traits project][0].
|
|
|
|
In my previous talks and workshops, and my email course, I haven't covered Drupal Test Traits and stuck to using the existing Drupal test types - `BrowserTestBase`, `KernelTestBase`, etc.
|
|
|
|
I maybe assumed that it was a different approach to testing, like introducing a different testing tool.
|
|
|
|
I wanted to make sure I understood Drupal's core test types before looking into additional things like Drupal Test Traits.
|
|
|
|
Now I've looked into it, I know it's not a replacement for Drupal core tests - it's an extension of them.
|
|
|
|
It uses the same PHPUnit framework, but extends it with specific traits and classes for testing an existing Drupal site rather than creating a temporary website for each test.
|
|
|
|
This makes the setup much simpler, and easier for people to write their first working test.
|
|
|
|
And you can mix and match - not every test needs to implement the `ExistingSiteBase` class that Drupal Test Traits provides.
|
|
|
|
If a test is better written as a standard Functional test, you can still use the core classes as you need to.
|
|
|
|
You can even include the specific traits you need, giving you full control and flexibility.
|
|
|
|
I'll continue to teach the Drupal testing fundamentals, but in future versions, I'll include Drupal Test Traits too, and I'll be using it for any Drupal projects for clients or [my own website][1].
|
|
|
|
[0]: /daily/2025/06/18/exploring-drupal-test-traits
|
|
[1]: https://code.oliverdavies.uk/opdavies/oliverdavies.uk
|
|
format: markdown
|
|
processed: |
|
|
<p>I've recently been looking into <a href="http://localhost:8888/daily/2025/06/18/exploring-drupal-test-traits">the Drupal Test Traits project</a>.</p>
|
|
<p>In my previous talks and workshops, and my email course, I haven't covered Drupal Test Traits and stuck to using the existing Drupal test types - <code>BrowserTestBase</code>, <code>KernelTestBase</code>, etc.</p>
|
|
<p>I maybe assumed that it was a different approach to testing, like introducing a different testing tool.</p>
|
|
<p>I wanted to make sure I understood Drupal's core test types before looking into additional things like Drupal Test Traits.</p>
|
|
<p>Now I've looked into it, I know it's not a replacement for Drupal core tests - it's an extension of them.</p>
|
|
<p>It uses the same PHPUnit framework, but extends it with specific traits and classes for testing an existing Drupal site rather than creating a temporary website for each test.</p>
|
|
<p>This makes the setup much simpler, and easier for people to write their first working test.</p>
|
|
<p>And you can mix and match - not every test needs to implement the <code>ExistingSiteBase</code> class that Drupal Test Traits provides.</p>
|
|
<p>If a test is better written as a standard Functional test, you can still use the core classes as you need to.</p>
|
|
<p>You can even include the specific traits you need, giving you full control and flexibility.</p>
|
|
<p>I'll continue to teach the Drupal testing fundamentals, but in future versions, I'll include Drupal Test Traits too, and I'll be using it for any Drupal projects for clients or <a href="https://code.oliverdavies.uk/opdavies/oliverdavies.uk">my own website</a>.</p>
|
|
summary: ''
|
|
field_daily_email_cta:
|
|
- target_type: node
|
|
target_uuid: e3f6c728-7855-4804-8614-e2a0c08c368f
|