Skip to content

Commit 723a21e

Browse files
Fix running tests instructions
1 parent d588c37 commit 723a21e

1 file changed

Lines changed: 91 additions & 91 deletions

File tree

tests/RUNNING_TESTS.md

Lines changed: 91 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,143 +1,143 @@
11
# Running Unit Tests for Agent365-Python SDK
22

3-
## Quick Start
3+
This guide covers setting up and running tests in Visual Studio Code.
44

5-
```bash
6-
# Install dependencies
7-
uv pip install -e libraries/microsoft-agents-a365-runtime
8-
uv pip install pytest pytest-cov pytest-asyncio
5+
---
96

10-
# Run all tests
11-
python -m pytest tests/
7+
## Prerequisites
128

13-
# Run with coverage
14-
python -m pytest tests/runtime/ --cov=microsoft_agents_a365.runtime --cov-report=html
15-
```
9+
- **Python 3.11+** installed
10+
- **Visual Studio Code** with Python extension
11+
- **Git** repository cloned locally
1612

1713
---
1814

19-
## Current Test Status
15+
## Test Structure
2016

21-
| Module | Tests | Status |
22-
|--------|-------|--------|
23-
| Runtime | 53 | ✅ Complete |
24-
| Observability | ~20 | ⚠️ Partial |
25-
| Tooling | 0 | ❌ Not Started |
26-
| Notifications | 0 | ❌ Not Started |
17+
> **Note:** This structure will be updated as new tests are added.
2718
28-
**Coverage Target:** 80%+ | See [TEST_PLAN.md](TEST_PLAN.md) for roadmap
19+
```plaintext
20+
tests/
21+
├── runtime/ # Runtime tests
22+
├── observability/ # Observability tests
23+
├── tooling/ # Tooling tests
24+
└── notifications/ # Notifications tests
25+
```
2926

3027
---
3128

32-
## Installation
29+
## Initial Setup
3330

34-
```bash
35-
# Runtime module only
36-
uv pip install -e libraries/microsoft-agents-a365-runtime
37-
uv pip install pytest pytest-cov pytest-asyncio
38-
39-
# All modules
40-
uv pip install -e libraries/microsoft-agents-a365-observability-core
41-
uv pip install -e libraries/microsoft-agents-a365-tooling
42-
uv pip install -e libraries/microsoft-agents-a365-notifications
43-
```
31+
### 1. Configure Python Environment
4432

45-
---
33+
1. Press `Ctrl+Shift+P`
34+
2. Type "Python: Select Interpreter"
35+
3. Choose your Python 3.11+ interpreter
4636

47-
## Running Tests
37+
### 2. Install Dependencies
4838

49-
```bash
50-
# All tests
51-
python -m pytest tests/
39+
```powershell
40+
# Install test dependencies
41+
uv pip install pytest pytest-asyncio pytest-mock pytest-cov pytest-html
5242
53-
# Specific module
54-
python -m pytest tests/runtime/
43+
# Install workspace packages
44+
uv pip install -e .
45+
```
5546

56-
# Specific file
57-
python -m pytest tests/runtime/test_environment_utils.py
47+
---
5848

59-
# Specific test
60-
python -m pytest tests/runtime/test_environment_utils.py::TestEnvironmentUtils::test_constants
49+
## Running Tests in VS Code
6150

62-
# With verbose output
63-
python -m pytest tests/runtime/ -v
51+
### Test Explorer
6452

65-
# Stop on first failure
66-
python -m pytest tests/runtime/ -x
53+
1. Click the beaker icon in the Activity Bar or press `Ctrl+Shift+P` → "Test: Focus on Test Explorer View"
54+
2. Click the play button to run tests (all/folder/file/individual)
55+
3. Right-click → "Debug Test" to debug with breakpoints
6756

68-
# Pattern matching
69-
python -m pytest tests/runtime/ -k "environment"
57+
### Command Palette
7058

71-
# Re-run failed tests only
72-
python -m pytest --lf
73-
```
59+
- `Test: Run All Tests`
60+
- `Test: Run Tests in Current File`
61+
- `Test: Debug Tests in Current File`
7462

7563
---
7664

77-
## Coverage Reports
65+
## Running Tests from Command Line
7866

79-
```bash
80-
# Terminal output
81-
python -m pytest tests/runtime/ --cov=microsoft_agents_a365.runtime --cov-report=term-missing
67+
```powershell
68+
# Run all tests
69+
python -m pytest tests/
8270
83-
# HTML report (opens htmlcov/index.html)
84-
python -m pytest tests/runtime/ --cov=microsoft_agents_a365.runtime --cov-report=html
71+
# Run specific module/file
72+
python -m pytest tests/runtime/
73+
python -m pytest tests/runtime/test_environment_utils.py
8574
86-
# XML report (for CI/CD tools)
87-
python -m pytest tests/runtime/ --cov=microsoft_agents_a365.runtime --cov-report=xml
75+
# Run with options
76+
python -m pytest tests/ -v # Verbose
77+
python -m pytest tests/ -x # Stop on first failure
78+
python -m pytest tests/ -k "environment" # Pattern matching
79+
python -m pytest --lf # Re-run failed tests
8880
```
8981

9082
---
9183

92-
## Advanced Options
84+
## Generating Reports
9385

94-
```bash
95-
# Parallel execution
96-
uv pip install pytest-xdist
97-
python -m pytest tests/runtime/ -n auto
86+
### HTML Reports
9887

99-
# JUnit XML report
100-
python -m pytest tests/runtime/ --junitxml=test-results.xml
101-
```
102-
103-
---
88+
```powershell
89+
# Coverage report
90+
python -m pytest tests/ --cov=libraries --cov-report=html
91+
Invoke-Item htmlcov\index.html
10492
105-
## Understanding Output
93+
# Test report
94+
python -m pytest tests/ --html=test-report.html --self-contained-html
95+
Invoke-Item test-report.html
10696
97+
# Combined
98+
python -m pytest tests/ --cov=libraries --cov-report=html --html=test-report.html --self-contained-html -v
10799
```
108-
tests/runtime/test_environment_utils.py::TestEnvironmentUtils::test_constants PASSED [ 1%]
109-
=================================== 53 passed in 0.18s ===================================
110-
```
111100

112-
| Status | Description |
113-
|--------|-------------|
114-
| **PASSED** | Test passed successfully |
115-
| **FAILED** | Test failed (shows error details) |
116-
| **SKIPPED** | Test skipped |
117-
| **ERROR** | Error during collection/setup |
101+
### CI/CD Reports
102+
103+
```powershell
104+
# XML reports for CI/CD pipelines
105+
python -m pytest tests/ --cov=libraries --cov-report=xml --junitxml=test-results.xml
106+
```
118107

119108
---
120109

121110
## Troubleshooting
122111

112+
### Common Issues
113+
123114
| Issue | Solution |
124115
|-------|----------|
125-
| `ModuleNotFoundError` | `uv pip install -e libraries/microsoft-agents-a365-runtime` |
126-
| `pytest: command not found` | `uv pip install pytest` |
127-
| `ERROR: unrecognized arguments: --cov` | `uv pip install pytest-cov` |
116+
| **Test loading failed** | Clean pyproject.toml, reinstall packages, restart VS Code |
117+
| **ImportError: No module named 'pytest'** | `uv pip install pytest pytest-asyncio pytest-mock` |
118+
| **ImportError: No module named 'microsoft_agents_a365'** | `uv pip install -e .` |
119+
| **Tests not discovered** | Refresh Test Explorer or restart VS Code |
128120

129-
---
121+
### Fix Steps
130122

131-
## Test Structure
123+
If tests fail to discover or import errors occur:
132124

125+
**1. Clean pyproject.toml**
126+
127+
```powershell
128+
$content = Get-Content "pyproject.toml" -Raw
129+
$fixed = $content -replace "`r`n", "`n"
130+
$fixed | Set-Content "pyproject.toml" -NoNewline
133131
```
134-
tests/
135-
├── README.md # Overview
136-
├── RUNNING_TESTS.md # This file
137-
├── TEST_PLAN.md # Test strategy
138-
└── runtime/
139-
├── test_environment_utils.py # 16 tests
140-
├── test_version_utils.py # 12 tests
141-
├── test_utility.py # 13 tests
142-
└── test_power_platform_api_discovery.py # 12 tests
132+
133+
**2. Reinstall packages**
134+
135+
```powershell
136+
uv pip install -e .
143137
```
138+
139+
**3. Restart VS Code**
140+
141+
- Close completely and reopen
142+
- Wait for Python extension to reload
143+
- Refresh Test Explorer

0 commit comments

Comments
 (0)