{
  "id": 5806315,
  "title": "Anatomy of a Test",
  "url": "https://urgent.news/2026/09/05/anatomy-of-a-test",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-05T17:50:08.000Z",
  "source": {
    "name": "Lobsters",
    "slug": "lobsters",
    "url": "https://jonathan-frere.com/posts/anatomy-of-a-test/"
  },
  "original_language": "en",
  "account": "Recently, I wrote a test case for a bookmark app I've been working on recently. The app scrapes links, tags them, indexes the content for later full-text search, and archives it. The test is for a specific function in the src/bookmarker/store.gleam file. This function, store.start_job(conn, job), is responsible for marking a job as started and removing it from the pending jobs list.\n\nThe context here is that the project is written in Gleam, a functional programming language. Gleam has a convention of placing tests alongside the file being tested, but this isn't possible in Gleam, so I use a test/ directory with the same path/folder structure as the src/ directory. The name of the test file is an artifact of how Gleam's standard testing library works, and I prefer writing test names as strings for easier readability.\n\nWhen writing test names, I aim to indicate the goal of the test, which may change over time, but the test name should remain fairly constant. This approach is inspired by a comment in Matklad's article about testing, though I can't confirm that.\n\nIn this test, I encapsulate the boilerplate code required to create dependencies like an SQLite connection, a mock clock, and some teardown logic. I prefer tests that manipulate the dependencies directly because they tend to be more brittle when tests are manipulating the mocks or dependencies.\n\nIn this test, I'm asserting that calling store.start_job(conn, job) will mark the job as started and remove it from the pending jobs list. The \"arrange, act, assert\" model of testing is a good rule of thumb, and most of my tests naturally fall into this pattern. The lines of code in the test are the \"arrange\" part.",
  "summary": null,
  "key_points": [
    "Test case written for bookmark app's store.startjob function",
    "Gleam programming language used for the project",
    "Test name indicates goal, remains constant over time"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}