@@ -34,11 +34,18 @@ project and how to get started as a developer.
3434
35354 . ** Run the Tests** :
3636 ``` bash
37- # Run all tests
37+ # Run all tests with unified coverage (unit + integration)
3838 just test
39- # or
40- uv run pytest -p pytest_mock -v
41-
39+
40+ # Run unit tests only (fast, no coverage)
41+ just test-unit
42+
43+ # Run integration tests only (fast, no coverage)
44+ just test-int
45+
46+ # Generate HTML coverage report
47+ just coverage
48+
4249 # Run a specific test
4350 pytest tests/path/to/test_file.py::test_function_name
4451 ```
@@ -134,7 +141,7 @@ agreement to the DCO.
134141
135142## Code Style Guidelines
136143
137- - ** Python Version** : Python 3.12+ with full type annotations
144+ - ** Python Version** : Python 3.12+ with full type annotations (3.12+ required for type parameter syntax)
138145- ** Line Length** : 100 characters maximum
139146- ** Formatting** : Use ruff for consistent styling
140147- ** Import Order** : Standard lib, third-party, local imports
@@ -144,12 +151,78 @@ agreement to the DCO.
144151
145152## Testing Guidelines
146153
147- - ** Coverage Target** : We aim for 100% test coverage for all code
154+ ### Test Structure
155+
156+ Basic Memory uses two test directories with unified coverage reporting:
157+
158+ - ** ` tests/ ` ** : Unit tests that test individual components in isolation
159+ - Fast execution with extensive mocking
160+ - Test individual functions, classes, and modules
161+ - Run with: ` just test-unit ` (no coverage, fast)
162+
163+ - ** ` test-int/ ` ** : Integration tests that test real-world scenarios
164+ - Test full workflows with real database and file operations
165+ - Include performance benchmarks
166+ - More realistic but slower than unit tests
167+ - Run with: ` just test-int ` (no coverage, fast)
168+
169+ ### Running Tests
170+
171+ ``` bash
172+ # Run all tests with unified coverage report
173+ just test
174+
175+ # Run only unit tests (fast iteration)
176+ just test-unit
177+
178+ # Run only integration tests
179+ just test-int
180+
181+ # Generate HTML coverage report
182+ just coverage
183+
184+ # Run specific test
185+ pytest tests/path/to/test_file.py::test_function_name
186+
187+ # Run tests excluding benchmarks
188+ pytest -m " not benchmark"
189+
190+ # Run only benchmark tests
191+ pytest -m benchmark test-int/test_sync_performance_benchmark.py
192+ ```
193+
194+ ### Performance Benchmarks
195+
196+ The ` test-int/test_sync_performance_benchmark.py ` file contains performance benchmarks that measure sync and indexing speed:
197+
198+ - ` test_benchmark_sync_100_files ` - Small repository performance
199+ - ` test_benchmark_sync_500_files ` - Medium repository performance
200+ - ` test_benchmark_sync_1000_files ` - Large repository performance (marked slow)
201+ - ` test_benchmark_resync_no_changes ` - Re-sync performance baseline
202+
203+ Run benchmarks with:
204+ ``` bash
205+ # Run all benchmarks (excluding slow ones)
206+ pytest test-int/test_sync_performance_benchmark.py -v -m " benchmark and not slow"
207+
208+ # Run all benchmarks including slow ones
209+ pytest test-int/test_sync_performance_benchmark.py -v -m benchmark
210+
211+ # Run specific benchmark
212+ pytest test-int/test_sync_performance_benchmark.py::test_benchmark_sync_100_files -v
213+ ```
214+
215+ See ` test-int/BENCHMARKS.md ` for detailed benchmark documentation.
216+
217+ ### Testing Best Practices
218+
219+ - ** Coverage Target** : We aim for high test coverage for all code
148220- ** Test Framework** : Use pytest for unit and integration tests
149- - ** Mocking** : Use pytest-mock for mocking dependencies only when necessary
221+ - ** Mocking** : Avoid mocking in integration tests; use sparingly in unit tests
150222- ** Edge Cases** : Test both normal operation and edge cases
151223- ** Database Testing** : Use in-memory SQLite for testing database operations
152224- ** Fixtures** : Use async pytest fixtures for setup and teardown
225+ - ** Markers** : Use ` @pytest.mark.benchmark ` for benchmarks, ` @pytest.mark.slow ` for slow tests
153226
154227## Release Process
155228
0 commit comments