{
  "id": 9454242,
  "title": "Unit Tests vs. Regression Tests: Why the Same Feature Gets Tested Twice",
  "url": "https://urgent.news/2026/09/24/unit-tests-vs-regression-tests-why-the-same-feature-gets-tested-twice",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-24T00:54:59.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/susumun/unit-tests-vs-regression-tests-why-the-same-feature-gets-tested-twice-1mf6"
  },
  "original_language": "en",
  "account": "In the maintenance tool's test suite, you'll often encounter functions with two tests for seemingly similar behavior. This discrepancy arises from the distinction between unit tests and regression tests, each serving different purposes.\n\nUnit tests verify functions in isolation. They take a function, feed it a range of plausible inputs, and check if the output matches expectations. These tests are written alongside or shortly after the implemented function, ensuring the function behaves as designed. The example given is a helper function that diagnoses and fixes SSH private key permission issues. The test methods in this case feed various plausible inputs to the is_permission_error() function and check the return value. The primary goal of a unit test is to confirm whether a function behaves as per its contract, independent of any external factors.\n\nOn the other hand, regression tests aim to seal off an incident that has already occurred, ensuring it doesn't resurface in future code changes. These tests are triggered by the realization that a previously fixed bug has resurfaced. The example provided is a pre-build version-consistency script (tools/bump_version.py) that printed a success message containing an emoji. On Windows with a Japanese locale, the script crashed due to a UnicodeEncodeError when running as a subprocess with its output piped. This incident led to the creation of tests/test_windows_cp932_safety.py, which consists of two layers.\n\nLayer 1 is a static check that scans the source of any script that runs as a subprocess during build/release, character by character, to ensure no content fails to encode as cp932. Layer 2 is a behavioral check that runs the target script as a child process with PYTHONIOENCODING set to cp932, confirming it exits cleanly (return code 0) without raising UnicodeEncodeError.\n\nThe filenames of the tests, such as test_stability_v47.py and test_db_backup_v48.py, signify regression tests. They are named after internal development round numbers and contain headers describing the specific incident they address. For instance, test_db_backup_v48.py addresses the os.path.join() behavior issue, where a remote absolute path was treated as absolute and the first argument was discarded. This test ensures that if a similar issue resurfaces, it will be caught early through automated testing.",
  "summary": "Look through a maintenance tool's test suite long enough and you'll run into a small puzzle: a function already has a test, so why does another file add a second one for what looks like the same behavior? Two tests that appear to cover the same ground can actually exist for entirely different reasons. This post walks through the distinction between \"unit tests\" and \"regression tests,\" using real…",
  "key_points": [],
  "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."
}