TEST-INFRA: [ci-execution-time] Optimize Unit Test Setup by Removing DB Migrations #2300

Open
opened 2026-04-03 13:25:36 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/ci-execution-time-unit-test-no-db-migrations
  • Commit Message: perf(tests): remove db migration step from unit_tests nox session
  • Milestone: v3.8.0
  • Parent Epic: #1678

Background and context

The unit_tests session in noxfile.py currently invokes the _create_template_db function, which builds a fully migrated SQLite database template. This is an excellent optimization for integration tests that require a realistic database schema, but it is an unnecessary and time-consuming step for unit tests.

Unit tests should be lightweight and fast, focusing on isolated components. They should not bear the overhead of database creation and migration. This step adds avoidable setup time to every run of the unit test suite.

Expected behavior

The unit_tests nox session should complete without building a migrated database template, reducing overall execution time while all unit tests continue to pass.

Subtasks

  • Remove Template Creation: In noxfile.py, remove the call to _create_template_db from the unit_tests session.
  • Adapt Test Environment: Modify the Behave environment setup (e.g., in features/environment.py) for unit tests to use an in-memory SQLite database or mock the database layer entirely, placing any mock logic under features/mocks/.
  • Validate Unit Tests: Confirm that all tests in the unit test suite pass without the pre-built database template and that coverage is maintained at ≥ 97%.

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • The unit_tests nox session completes without building a migrated database template.
  • The overall execution time of the unit_tests session is measurably reduced.
  • All unit tests continue to pass with the new, faster setup.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
  • All nox stages pass.
  • Coverage >= 97%

Automated by CleverAgents Bot
Supervisor: Test Infrastructure | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/ci-execution-time-unit-test-no-db-migrations` - **Commit Message**: `perf(tests): remove db migration step from unit_tests nox session` - **Milestone**: v3.8.0 - **Parent Epic**: #1678 ## Background and context The `unit_tests` session in `noxfile.py` currently invokes the `_create_template_db` function, which builds a fully migrated SQLite database template. This is an excellent optimization for integration tests that require a realistic database schema, but it is an unnecessary and time-consuming step for unit tests. Unit tests should be lightweight and fast, focusing on isolated components. They should not bear the overhead of database creation and migration. This step adds avoidable setup time to every run of the unit test suite. ## Expected behavior The `unit_tests` nox session should complete without building a migrated database template, reducing overall execution time while all unit tests continue to pass. ## Subtasks - [ ] **Remove Template Creation**: In `noxfile.py`, remove the call to `_create_template_db` from the `unit_tests` session. - [ ] **Adapt Test Environment**: Modify the Behave environment setup (e.g., in `features/environment.py`) for unit tests to use an in-memory SQLite database or mock the database layer entirely, placing any mock logic under `features/mocks/`. - [ ] **Validate Unit Tests**: Confirm that all tests in the unit test suite pass without the pre-built database template and that coverage is maintained at ≥ 97%. ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - The `unit_tests` nox session completes without building a migrated database template. - The overall execution time of the `unit_tests` session is measurably reduced. - All unit tests continue to pass with the new, faster setup. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. - All nox stages pass. - Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: Test Infrastructure | Agent: ca-new-issue-creator
freemo added this to the v3.8.0 milestone 2026-04-03 13:25:42 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#2300
No description provided.