Testing Overview
Automated tests run inside a live host so they can work with the active document and host API. RevitDevTool supports Python tests with pytest and .NET tests with Microsoft Testing Platform.
- pytest
NUnitTUnit
MSTest
Tests run on Revit and the AutoCAD family, 2022–2027. Pick the product with the host settings.
The package versions on these pages are the ones that work with the latest RevitDevTool.
Choose a Stack
| Stack | Framework | Package | Entry doc |
|---|---|---|---|
| .NET | NUnit 5.0.0 (default), TUnit 1.76.0, or MSTest 4.5.1 | NuGet: RevitDevTool.TestAdapter 0.1.4 | NUnit · TUnit · MSTest |
| CPython | pytest | PyPI: revitdevtool_pytest 0.5.0 | pytest |
| IronPython | unittest (TestCase) | Name files test_*_ipy.py; pytest discovers them as IronPython tests | unittest |
IronPython notes
- Name files
test_*_ipy.pyso the test client recognizes them as IronPython tests. - On Revit, engine preference matches IronPython execution: pyRevit first when installed, else IronPython 3.4.2. AutoCAD-family hosts use bundled IronPython 3.4.2.
- No pytest fixtures and no PEP 723. You can still debug IronPython tests: attach your IDE to the IronPython port before running (Attach Debugger).
- Mixed
test_*.py+test_*_ipy.pyunder oneconftest.pyis fine; separateconftest.pytrees require separate pytest invocations against the same host.
How tests run
- The runner starts or connects to the selected Autodesk application.
- Each test runs with the matching Python or .NET runtime, and the result comes back to your terminal or IDE.
- Tests that change a document should clean up after themselves and respect the host's transaction rules.
For .NET tests
- Add the
RevitDevTool.TestAdapterpackage. It runs NUnit, TUnit and MSTest inside the host through Microsoft Testing Platform2.5.1. - NUnit is the default. Set
TestingFrameworktotunitormstestto opt in. - Pin the framework package yourself; the adapter does not pull it.
Host settings
Every test run needs to know which host to use. The settings are the same for .NET and Python; only where you set them differs.
| Setting | .NET (.csproj) | pytest (CLI / pyproject.toml) | Meaning | Default |
|---|---|---|---|---|
| Host | HostName | --host / host_name | The product to test against. Required for .NET | revit for pytest |
| Version | HostVersion | --host-version / host_version | The Autodesk year. For .NET it must match the API references used to compile the tests | none; required for .NET and with force launch |
| Fresh host | ForceLaunch | --force-launch / force_launch | Start a new host instead of reusing a running one | false |
| Launch timeout | LaunchTimeout | --launch-timeout / launch_timeout | Seconds to wait for the host to start | 180 for .NET, 120 for pytest |
| Test timeout | PerTestTimeout | --per-test-timeout / per_test_timeout | Seconds allowed per test | 60 |
| Known host | not available | --host-pipe / host_pipe | Connect to a specific running host by pipe name | none |
Use these values to pick the product:
| Product | .NET HostName | pytest host_name |
|---|---|---|
| Revit | Revit | revit |
| AutoCAD | AutoCad | autocad |
| Civil 3D | Civil3D | civil3d |
| Plant 3D | Plant3D | plant3d |
| Map 3D | AcadMap3D | acadmap3d |
| Architecture | AcadArch | acadarch |
| Mechanical | AcadMech | acadmech |
| MEP | AcadMep | acadmep |
| Electrical | AcadElec | acadelec |
Use AutoCad / autocad for plain AutoCAD, and the product-specific value when you test against a vertical.
Leaf Docs
| Doc | Covers |
|---|---|
| pytest | CPython pytest setup, configuration, fixtures, PEP 723, --host table |
| NUnit · TUnit · MSTest | Microsoft Testing Platform project setup, pinned framework packages, CLI and debugger |
Samples: RevitDevTool.PyTest (Python) · DevTools.NUnit.SampleTests, DevTools.TUnit.SampleTests, DevTools.MSTest.SampleTests (.NET)
Troubleshooting: Troubleshooting · bridge connection issues · Known Limitations (IronPython split, sequential runs)