You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`src/client/testing/testController/common/projectAdapter.ts` — `ProjectAdapter` interface (represents a single Python project with its own test infrastructure).
32
+
-`src/client/testing/testController/common/projectUtils.ts` — utilities for project ID generation, display names, and shared adapter creation.
@@ -151,6 +155,51 @@ The adapters in the extension don't implement test discovery/run logic themselve
151
155
- Settings are consumed by `src/client/testing/common/testConfigurationManager.ts`, `src/client/testing/configurationFactory.ts`, and adapters under `src/client/testing/testController/*` which read settings to build CLI args and env for subprocesses.
152
156
- The setting definitions and descriptions are in `package.json` and localized strings in `package.nls.json`.
Project-based testing enables multi-project workspace support where each Python project gets its own test tree root with its own Python environment.
161
+
162
+
> **⚠️ Note: unittest support for project-based testing is NOT yet implemented.** Project-based testing currently only works with pytest. unittest support will be added in a future PR.
163
+
164
+
### Architecture
165
+
166
+
-**TestProjectRegistry** (`testProjectRegistry.ts`): Central registry that:
167
+
168
+
- Discovers Python projects via the Python Environments API
169
+
- Creates and manages `ProjectAdapter` instances per workspace
170
+
- Computes nested project relationships and configures ignore lists
171
+
- Falls back to "legacy" single-adapter mode when API unavailable
172
+
173
+
-**ProjectAdapter** (`projectAdapter.ts`): Interface representing a single project with:
174
+
- Project identity (ID, name, URI from Python Environments API)
1.**Activation**: When the extension activates, `PythonTestController` checks if the Python Environments API is available.
182
+
2.**Project discovery**: `TestProjectRegistry.discoverAndRegisterProjects()` queries the API for all Python projects in each workspace.
183
+
3.**Nested handling**: `configureNestedProjectIgnores()` identifies child projects and adds their paths to parent projects' ignore lists.
184
+
4.**Test discovery**: For each project, the controller calls `project.discoveryAdapter.discoverTests()` with the project's URI. The adapter sets `PROJECT_ROOT_PATH` environment variable for the Python runner.
185
+
5.**Python side**: `get_test_root_path()` in `vscode_pytest/__init__.py` returns `PROJECT_ROOT_PATH` (if set) or falls back to `cwd`.
186
+
6.**Test tree**: Each project gets its own root node in the Test Explorer, with test IDs scoped by project ID using the `||` separator.
187
+
188
+
### Logging prefix
189
+
190
+
All project-based testing logs use the `[test-by-project]` prefix for easy filtering in the output channel.
191
+
192
+
### Key files
193
+
194
+
- Python side: `python_files/vscode_pytest/__init__.py` — `get_test_root_path()` function and `PROJECT_ROOT_PATH` environment variable.
195
+
- TypeScript: `testProjectRegistry.ts`, `projectAdapter.ts`, `projectUtils.ts`, and the discovery adapters.
0 commit comments