|
| 1 | +# Running Unit Tests for Agent365-Python SDK |
| 2 | + |
| 3 | +## Quick Start |
| 4 | + |
| 5 | +```bash |
| 6 | +# Install dependencies |
| 7 | +uv pip install -e libraries/microsoft-agents-a365-runtime |
| 8 | +uv pip install pytest pytest-cov pytest-asyncio |
| 9 | + |
| 10 | +# Run all tests |
| 11 | +python -m pytest tests/ |
| 12 | + |
| 13 | +# Run with coverage |
| 14 | +python -m pytest tests/runtime/ --cov=microsoft_agents_a365.runtime --cov-report=html |
| 15 | +``` |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## Current Test Status |
| 20 | + |
| 21 | +| Module | Tests | Status | |
| 22 | +|--------|-------|--------| |
| 23 | +| Runtime | 53 | ✅ Complete | |
| 24 | +| Observability | ~20 | ⚠️ Partial | |
| 25 | +| Tooling | 0 | ❌ Not Started | |
| 26 | +| Notifications | 0 | ❌ Not Started | |
| 27 | + |
| 28 | +**Coverage Target:** 80%+ | See [TEST_PLAN.md](TEST_PLAN.md) for roadmap |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +## Installation |
| 33 | + |
| 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 | +``` |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +## Running Tests |
| 48 | + |
| 49 | +```bash |
| 50 | +# All tests |
| 51 | +python -m pytest tests/ |
| 52 | + |
| 53 | +# Specific module |
| 54 | +python -m pytest tests/runtime/ |
| 55 | + |
| 56 | +# Specific file |
| 57 | +python -m pytest tests/runtime/test_environment_utils.py |
| 58 | + |
| 59 | +# Specific test |
| 60 | +python -m pytest tests/runtime/test_environment_utils.py::TestEnvironmentUtils::test_constants |
| 61 | + |
| 62 | +# With verbose output |
| 63 | +python -m pytest tests/runtime/ -v |
| 64 | + |
| 65 | +# Stop on first failure |
| 66 | +python -m pytest tests/runtime/ -x |
| 67 | + |
| 68 | +# Pattern matching |
| 69 | +python -m pytest tests/runtime/ -k "environment" |
| 70 | + |
| 71 | +# Re-run failed tests only |
| 72 | +python -m pytest --lf |
| 73 | +``` |
| 74 | + |
| 75 | +--- |
| 76 | + |
| 77 | +## Coverage Reports |
| 78 | + |
| 79 | +```bash |
| 80 | +# Terminal output |
| 81 | +python -m pytest tests/runtime/ --cov=microsoft_agents_a365.runtime --cov-report=term-missing |
| 82 | + |
| 83 | +# HTML report (opens htmlcov/index.html) |
| 84 | +python -m pytest tests/runtime/ --cov=microsoft_agents_a365.runtime --cov-report=html |
| 85 | + |
| 86 | +# XML report (for CI/CD tools) |
| 87 | +python -m pytest tests/runtime/ --cov=microsoft_agents_a365.runtime --cov-report=xml |
| 88 | +``` |
| 89 | + |
| 90 | +--- |
| 91 | + |
| 92 | +## Advanced Options |
| 93 | + |
| 94 | +```bash |
| 95 | +# Parallel execution |
| 96 | +uv pip install pytest-xdist |
| 97 | +python -m pytest tests/runtime/ -n auto |
| 98 | + |
| 99 | +# JUnit XML report |
| 100 | +python -m pytest tests/runtime/ --junitxml=test-results.xml |
| 101 | +``` |
| 102 | + |
| 103 | +--- |
| 104 | + |
| 105 | +## Understanding Output |
| 106 | + |
| 107 | +``` |
| 108 | +tests/runtime/test_environment_utils.py::TestEnvironmentUtils::test_constants PASSED [ 1%] |
| 109 | +=================================== 53 passed in 0.18s =================================== |
| 110 | +``` |
| 111 | + |
| 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 | |
| 118 | + |
| 119 | +--- |
| 120 | + |
| 121 | +## Troubleshooting |
| 122 | + |
| 123 | +| Issue | Solution | |
| 124 | +|-------|----------| |
| 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` | |
| 128 | + |
| 129 | +--- |
| 130 | + |
| 131 | +## Test Structure |
| 132 | + |
| 133 | +``` |
| 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 |
| 143 | +``` |
0 commit comments