Unit and integration tests
Example-based tests that run the code and assert on behaviour, from single functions up to services with real dependencies.
Sub-techniques
4
| ID | Name | Description |
|---|---|---|
V1019.001 | Unit tests | Fast, isolated tests per function or class. |
V1019.002 | Integration tests with real services | Run against real databases and queues in containers instead of mocks. |
V1019.003 | Regression test per bug | Every fixed bug gets a test that failed before the fix. |
V1019.004 | Coverage gate | Fail when coverage of changed lines drops below a threshold. |
Craft it
- Write the failing test before the fix for every bug.
- Run integration tests against containers, not mocks, for storage and messaging code.
- Gate on coverage of changed lines, not overall coverage.
Reverse engineer it
Signs that a codebase already runs this technique, and where to read how it is configured.
- tests/ or *_test.* files, plus test config in pyproject.toml, jest.config or vitest.config.
- A CI test job and a coverage upload step.
Where the scanned repositories configure it:
.github/workflows/*.ymlin 138 repositoriespackage.jsonin 76 repositoriesvitest.config.tsin 32 repositoriesMakefilein 31 repositoriespyproject.tomlin 26 repositoriesvitest.config.mtsin 11 repositories
Detected by the scanner as: Unit and integration tests (behaviour regressions on the paths the tests exercise.)
Open-source packages
4
- pytest pytest-dev/pytest
- Jest jestjs/jest
- Vitest vitest-dev/vitest
- Testcontainers (Python) testcontainers/testcontainers-python
Tools seen in scans
by repositories that run them
| Tool | Repos | Command seen | Runs in | Docs |
|---|---|---|---|---|
vitest |
91 | vitest run |
ci, local | docs |
pytest |
77 | pytest |
pre-commit, ci, local | docs |
cargo-test |
44 | cargo test --locked |
ci, local | docs |
jest |
38 | jest |
ci, local | docs |
node-test |
35 | node --test scripts/*.test.js |
ci, local | docs |
go-test |
29 | go test ./... |
pre-commit, ci, local | docs |
unittest |
20 | unittest discover -s .github/scripts -p test_check_diff.py |
ci, local | docs |
mocha |
10 | mocha test/unit/node/index.js --delay --ui=tdd --exit |
ci, local | docs |
Procedure examples
repositories that run it, most-starred first; 40 of 166
| Repository | Tools | Runs in | Evidence |
|---|---|---|---|
| freeCodeCamp/freeCodeCamp | vitest |
local | api/package.json scripts.test |
| facebook/react | cargo-test |
ci | .github/workflows/compiler_rust.yml jobs.rust.steps[8] |
| nousresearch/hermes-agent | cargo-test, node-test, pytest, vitest |
ci, local | .github/workflows/rust-tests.yml jobs.bootstrap-installer.steps[3] (cargo test) |
| TheAlgorithms/Python | pytest |
ci | .github/workflows/build.yml jobs.build.steps[4] (Run tests) |
| microsoft/vscode | cargo-test, mocha, node-test |
ci, local | .github/workflows/pr-linux-cli-test.yml jobs.cli.steps[7] (🧪 Run unit tests) |
| avelino/awesome-go | go-test |
ci | .github/workflows/run-check.yaml jobs.build.steps[2] (run script) |
| ollama/ollama | go-test |
ci | .github/workflows/test-tokenizer.yaml jobs.reference.steps[3] (Test published... |
| langchain-ai/langchain | pytest, unittest |
ci | .github/workflows/_compile_integration_test.yml jobs.build.steps[3] (🔗 Check ... |
| iptv-org/iptv | vitest |
local | package.json scripts.test |
| vercel/next.js | cargo-test, jest |
ci, local | .github/workflows/test-turbopack-rust-bench-test.yml jobs.test.steps[8] (Buil... |
| 30-seconds/30-seconds-of-code | vitest |
ci, local | .github/workflows/test.yml jobs.js_tests.steps[3] |
| facebook/react-native | jest |
local | package.json scripts.test-ci |
| n8n-io/n8n | node-test, pytest |
ci, local | package.json scripts.seed:test |
| electron/electron | go-test, node-test |
ci | .github/workflows/pipeline-segment-build-siso.yml jobs.build.steps[7] (Test p... |
| langgenius/dify | go-test, node-test, pytest, unittest |
ci, local | .github/workflows/sandbox-runtime-tests.yml jobs.sandbox-runtime-unit.steps[2... |
| nodejs/node | unittest |
local | Makefile target tooltest (line 290) |
| langflow-ai/langflow | jest, pytest |
ci, local | .github/workflows/smoke-tests.yml jobs.frontend-smoke-tests.steps[3] (Run fro... |
| axios/axios | node-test, vitest |
ci, local | docs/package.json scripts.docs:build |
| microsoft/typescript | go-test |
ci | .github/workflows/ci.yml jobs.go-test.steps[3] (Tests without Node.js) |
| rust-lang/rust | cargo-test |
ci | .github/workflows/ci.yml jobs.calculate_matrix.steps[1] (Test citool) |
| mui/material-ui | vitest |
local | package.json scripts.vitest |
| fatedier/frp | go-test, vitest |
ci, local | Makefile target gotest (line 48) |
| ant-design/ant-design | jest, vitest |
ci, local | package.json scripts.predeploy |
| pytorch/pytorch | unittest |
ci | .github/workflows/distributed-triage-pi.yml jobs.prepare.steps[1] (Contract t... |
| mermaid-js/mermaid | vitest |
ci, local | .github/workflows/test.yml jobs.unit-test.steps[4] (Run Unit Tests) |
| supabase/supabase | vitest |
ci | .github/workflows/docs-js-libs-update.yml jobs.update-docs.steps[5] (Refresh ... |
| django/django | unittest |
ci | .github/workflows/tests.yml jobs.scripts-tests.steps[2] |
| comfyanonymous/ComfyUI | pytest |
ci | .github/workflows/test-execution.yml jobs.test.steps[3] (Run Execution Tests) |
| sveltejs/svelte | vitest |
ci, local | .github/workflows/ci.yml jobs.Tests.steps[3] |
| ggml-org/llama.cpp | vitest |
ci | .github/workflows/ui-build.yml jobs.build.steps[5] (Run PWA unit tests (versi... |
| home-assistant/core | pytest |
ci | .github/workflows/ci.yaml jobs.hassfest.steps[3] (Test hassfest package) |
| infiniflow/ragflow | jest, pytest |
ci, local | web/package.json scripts.test |
| earendil-works/pi | cargo-test, node-test, vitest |
ci, local | .github/workflows/env.yml jobs.tests.steps[4] (Daemon format, lint and unit t... |
| oven-sh/bun | cargo-test |
ci | .github/workflows/rust-lints.yml jobs.lolhtml.steps[2] (cargo test) |
| microsoft/markitdown | pytest |
ci | .github/workflows/tests.yml jobs.ocr-tests.steps[4] (Run tests) |
| pallets/flask | pytest |
ci, local | .github/workflows/tests.yaml jobs.tests.steps[3] |
| unionlabs/union | vitest |
local | app2/package.json scripts.test:watch |
| vitejs/vite | vitest |
ci, local | .github/workflows/ci.yml jobs.test.steps[9] (Test unit) |
| elastic/elasticsearch | vitest |
local | .buildkite/package.json scripts.test |
| TauricResearch/TradingAgents | pytest |
ci | .github/workflows/ci.yml jobs.test.steps[3] (Run test suite) |