{
  "source_file": "0930",
  "source_platform": "Dev.to",
  "author": "Panagiotis Gkilis",
  "title_listed": "Ten Tests, Written Before the Code. The One That Failed Taught Me the Most",
  "keywords": "",
  "domain": "大模型算法",
  "content_type": "工程实践",
  "is_paid_flag": "否",
  "url": "https://dev.to/bedvibe_studios/ten-tests-written-before-the-code-the-one-that-failed-taught-me-the-most-35ng",
  "publish_date": "2026-08-20",
  "corpus_stage": "",
  "notes": "",
  "id": "9fa4aa45a15f",
  "collected_at": "2026-10-02T13:52:22",
  "title": "Ten Tests, Written Before the Code. The One That Failed Taught Me the Most - DEV Community",
  "body_markdown": "There is a number in solid mechanics that is exactly 3.\nTake an infinite plate with a circular hole, pull it in one direction, and the stress right at the edge of the hole is exactly three times the stress far away. Kirsch worked it out analytically in 1898. It is not approximately 3. It is 3.\nI wrote a finite element solver from scratch and never told it that number. It came back with\n3.00002\n.\nWhat \"from scratch\" means here\nNo FEA library. No scipy. The Delaunay mesher, the isoparametric elements, the global assembly and the conjugate-gradient solver are all my own code.\nThat constraint was the point. Calling a library and getting 3 proves the library works.\nConfiguration                                  K_t        error\nAnnulus, P2 curved, finest mesh (21,220 dof)   2.99981    0.0063 %\nAnnulus, extrapolated to h = 0                 3.00002    0.0005 %\nFinite plate, extrapolated                     2.99970    0.0101 %\nConservative Richardson variant                2.99937    0.0211 %\nEnter fullscreen mode\nExit fullscreen mode\nHitting the number is the weak evidence\nThis is the part I want to argue for, because it applies well beyond numerical code.\nLanding on 3 could be luck. A bug that happens to cancel, a mesh that happens to flatter you, a fudge factor someone tuned until the output looked right. One number matching one expected value is the weakest test you can run — and it is the test most of us stop at.\nThe strong evidence is the\nrate\n. Finite element theory predicts exactly how fast the error must shrink as the mesh gets finer, and the rate is different for each element type. You cannot fake that by accident.\nElement        L2 rate  predicted   H1 rate  predicted   energy  predicted\nP1 (linear)      2.026      2         1.019      1        2.000      2\nP2 (quadratic)   3.249      3         2.013      2        3.988      4\nEnter fullscreen mode\nExit fullscreen mode\nSix numbers, six predictions, all recovered. That is what says the implementation is right rather than coincidentally close.\nWriting the tests before the code\nI registered ten acceptance gates in a literature audit\nbefore any code existed\n. Quadrature exactness, patch tests, mesh validity, checking the iterative solver against a direct one, scale invariance, convergence orders for both element types.\nThe reason is not discipline for its own sake. It is that I know myself. If I write the criteria after seeing the output, I will unconsciously write criteria the output passes. Registering them first means the standard cannot move.\nNine gates passed. One did not.\nGate I failed, and it is published\nGate I concerned a variational crime — an approximation in how the curved boundary is handled. It failed. I tested two hypotheses for why and both were refuted.\nWhat is published is an arithmetic account consistent with every number I measured, plus a plain statement that the discrepancy\ncannot be settled from this experiment and is not settled\n. The literature figure I had written the gate against turned out to come from a search summary rather than a paper I had actually opened. That is in the record too.\nI could have deleted the gate. Nobody would have known it existed, because I wrote it myself, before the code, in a document nobody had read.\nThe gate that passed for the wrong reason\nThis one I am more pleased with than the failure.\nGate H passed. Then I went back and criticised it: the acceptance band I had written was the wrong\nshape\nfor a one-sided theorem. It should have been a one-sided bound, and I had written a two-sided one. The result was fine, but the test would have passed things it should have caught.\nNo reviewer forced that. A passing test that passes for the wrong reason is a bug in your test suite that no failure will ever reveal to you.\nMaking the central claim checkable instead of asserted\nThe whole thing rests on \"the target was never an input.\" That is easy to say and easy to lie about.\nSo the README documents it as something you can verify: grep the source for the target value, and the only hits you find are ones that never feed the computation. You do not have to believe me. You can run\ngrep\nin about four seconds.\nThe full run reproduces with\npython fem_003.py\nin roughly fifty seconds, with a\n--smoke\nmode for a quick shake-out, and it ships its own evidence — gate report, convergence CSVs, hoop-stress CSV, mesh and convergence plots.\nThe honest framing\nThis is reproduction and validation, not discovery. Kirsch published the analytic solution in 1898 and the convergence theory is in every textbook. Nothing here is new.\nThe contribution is building the thing and demonstrating that it lands on a number it was never given, with the rates it was supposed to have, against criteria written before the first line of code.\nIf you take one thing from this:\nwrite your acceptance criteria before you write the thing, publish the ones that fail, and go back and check whether the ones that passed deserved to.\nFull write-up:\nTen tests, written before the code\nCode, data and the full gate report:\n10.5281/zenodo.21892064",
  "metadata": {
    "title": "Ten Tests, Written Before the Code. The One That Failed Taught Me the Most - DEV Community",
    "description": "I wrote the acceptance criteria before writing any code, so I couldn't move the goalposts. Nine gates passed, one failed, and I published the failure. Tagged with testing, python, programming, science.",
    "keywords": "testing, python, programming, science, software, coding, development, engineering, inclusive, community",
    "author": null,
    "og:type": "article",
    "og:url": "https://dev.to/bedvibe_studios/ten-tests-written-before-the-code-the-one-that-failed-taught-me-the-most-35ng",
    "og:title": "Ten Tests, Written Before the Code. The One That Failed Taught Me the Most",
    "og:description": "I wrote the acceptance criteria before writing any code, so I couldn't move the goalposts. Nine gates passed, one failed, and I published the failure.",
    "og:site_name": "DEV Community",
    "og:image": "https://media2.dev.to/dynamic/image/width=1200,height=627,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbqoax5ajd7nc9vr20qu6.png",
    "twitter:site": "@thepracticaldev",
    "twitter:creator": "@",
    "twitter:title": "Ten Tests, Written Before the Code. The One That Failed Taught Me the Most",
    "twitter:description": "I wrote the acceptance criteria before writing any code, so I couldn't move the goalposts. Nine gates passed, one failed, and I published the failure.",
    "twitter:card": "summary_large_image",
    "twitter:widgets:new-embed-design": "on",
    "twitter:image:src": "https://media2.dev.to/dynamic/image/width=1200,height=627,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbqoax5ajd7nc9vr20qu6.png"
  },
  "paywall": {
    "listed_paid": false,
    "detected": false,
    "marker": "",
    "public_only": false,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 200,
    "error": ""
  },
  "code_blocks": [
    {
      "file": "attachments/9fa4aa45a15f/code/body-000.txt",
      "chars": 332,
      "language": "text"
    },
    {
      "file": "attachments/9fa4aa45a15f/code/body-001.txt",
      "chars": 217,
      "language": "text"
    }
  ],
  "images": [],
  "audio": [],
  "videos": [],
  "links": [
    {
      "href": "https://ai.bedvibe.studio/fem-kirsch/",
      "label": "Ten tests, written before the code",
      "type": "a"
    },
    {
      "href": "https://doi.org/10.5281/zenodo.21892064",
      "label": "10.5281/zenodo.21892064",
      "type": "a"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-14T10:48:45Z",
  "source_url": "https://dev.to/bedvibe_studios/ten-tests-written-before-the-code-the-one-that-failed-taught-me-the-most-35ng",
  "papers": [],
  "actual_video_files": [],
  "body_chars": 5079,
  "expected_body_images": 0,
  "discovery_status": "ok",
  "delivery_status": "ok",
  "missing_reason": "",
  "raw_html": "attachments/9fa4aa45a15f/pages/source.html",
  "local_html": "attachments/9fa4aa45a15f/pages/article.html",
  "body_base_path": "attachments/9fa4aa45a15f/pages/",
  "body_markdown_path": "attachments/9fa4aa45a15f/pages/article.md"
}