oliverdavies.uk/content/node.9834732b-1b38-471a-b1bb-64471b27a2ee.yml

73 lines
2.3 KiB
YAML

uuid:
- value: 9834732b-1b38-471a-b1bb-64471b27a2ee
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:28+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: |
Why I prefer integration tests to unit tests
created:
- value: '2023-11-14T00:00:00+00:00'
changed:
- value: '2025-05-11T09:00:28+00:00'
promote:
- value: false
sticky:
- value: false
default_langcode:
- value: true
revision_translation_affected:
- value: true
path:
- alias: /daily/2023/11/14/why-i-prefer-integration-tests-to-unit-tests
langcode: en
body:
- value: |
<p>With unit tests, you need to mock <strong>everything</strong>.</p>
<p>If what you're testing has a dependency, you need to create and use a mock version.</p>
<p>If the mock has its own dependencies, you need to mock those, too.</p>
<p>I've written unit tests with mocks and accidentally only tested the mocks instead of the functionality I intended.</p>
<h2 id="here%27s-the-thing">Here's the thing</h2>
<p>With integration tests, you can use and test the real dependencies.</p>
<p>Whilst they may be slightly slower to run, I prefer the simpler setup, less need for mocks, and knowing the real services work - not just the mocked versions.</p>
format: full_html
processed: |
<p>With unit tests, you need to mock <strong>everything</strong>.</p>
<p>If what you're testing has a dependency, you need to create and use a mock version.</p>
<p>If the mock has its own dependencies, you need to mock those, too.</p>
<p>I've written unit tests with mocks and accidentally only tested the mocks instead of the functionality I intended.</p>
<h2 id="here%27s-the-thing">Here's the thing</h2>
<p>With integration tests, you can use and test the real dependencies.</p>
<p>Whilst they may be slightly slower to run, I prefer the simpler setup, less need for mocks, and knowing the real services work - not just the mocked versions.</p>
summary: null
field_daily_email_cta: { }