Nice3point.TUnit.Revit 2026.0.1

Prefix Reserved
dotnet add package Nice3point.TUnit.Revit --version 2026.0.1
                    
NuGet\Install-Package Nice3point.TUnit.Revit -Version 2026.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nice3point.TUnit.Revit" Version="2026.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nice3point.TUnit.Revit" Version="2026.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Nice3point.TUnit.Revit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Nice3point.TUnit.Revit --version 2026.0.1
                    
#r "nuget: Nice3point.TUnit.Revit, 2026.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Nice3point.TUnit.Revit@2026.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Nice3point.TUnit.Revit&version=2026.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Nice3point.TUnit.Revit&version=2026.0.1
                    
Install as a Cake Tool

Testing Framework for .Revit

Write unit tests for your Revit add-ins using the TUnit testing framework with source-generated tests, parallel execution, and Native AOT support.

Installation

You can install the Toolkit as a NuGet package.

The packages are compiled for specific versions of Revit. To support different versions of libraries in one project, use the RevitVersion property:


<PackageReference Include="Nice3point.TUnit.Revit" Version="$(RevitVersion).*"/>

The public version of this package does not contain implementation for the framework. An open source version is not currently planned due to Autodesk export regulations.

Writing your first test

Start by creating a new class inheriting from RevitApiTest:

public class MyTestClass : RevitApiTest
{

}

Add a method with [Test] and [TestExecutor<RevitThreadExecutor>] attributes:

public class MyTestClass : RevitApiTest
{
    [Test]
    [TestExecutor<RevitThreadExecutor>]
    public async Task MyTest()
    {
        
    }
}

This is your runnable test. The [TestExecutor<RevitThreadExecutor>] attribute ensures the test executes within Revit's single-threaded API context.

Running your tests

TUnit is built on top of the Microsoft.Testing.Platform. Combined with source-generated tests, running your tests is available in multiple ways.

dotnet run

For simple project execution, dotnet run is the preferred method, allowing easier command line flag passing.

cd 'C:/Your/Test/Directory'
dotnet run -c "Release R26"

dotnet test

dotnet test requires the configuration to target the desired Revit version.

cd 'C:/Your/Test/Directory'
dotnet test -c "Release R26"

dotnet exec

If your test project has already been built, use dotnet exec or dotnet with the .dll path:

cd 'C:/Your/Test/Directory/bin/Release R26/'
dotnet exec YourTestProject.dll

or

cd 'C:/Your/Test/Directory/bin/Release R26/'
dotnet YourTestProject.dll

Application testing

Test Revit application-level functionality:

public sealed class RevitApplicationTests : RevitApiTest
{
    [Test]
    [TestExecutor<RevitThreadExecutor>]
    public async Task Documents_Startup_IsEmpty()
    {
        var documents = Application.Documents.Cast<Document>();
        
        await Assert.That(documents).IsEmpty();
    }

    [Test]
    [TestExecutor<RevitThreadExecutor>]
    public async Task Create_XYZ_ValidDistance()
    {
        var point = Application.Create.NewXYZ(3, 4, 5);
        
        await Assert.That(point.DistanceTo(XYZ.Zero)).IsEqualTo(7).Within(0.1);
    }
}

Document testing

Test document-specific operations with setup and cleanup:

public sealed class RevitDocumentTests : RevitApiTest
{
    private static Document _documentFile = null!;

    [Before(Class)]
    [HookExecutor<RevitThreadExecutor>]
    public static void Setup()
    {
        _documentFile = Application.OpenDocumentFile($@"C:\Program Files\Autodesk\Revit {Application.VersionNumber}\Samples\rac_basic_sample_family.rfa");
    }

    [After(Class)]
    [HookExecutor<RevitThreadExecutor>]
    public static void Cleanup()
    {
        _documentFile.Close(false);
    }

    [Test]
    [NotInParallel]
    [TestExecutor<RevitThreadExecutor>]
    public async Task FilteredElementCollector_ElementTypes_ValidAssignable()
    {
        var elements = new FilteredElementCollector(_documentFile)
            .WhereElementIsElementType()
            .ToElements();
        
        using (Assert.Multiple())
        {
            await Assert.That(elements).IsNotEmpty();
            await Assert.That(elements).All().Satisfy(element => element.IsAssignableTo<ElementType>());
        }
    }

    [Test]
    [NotInParallel]
    [TestExecutor<RevitThreadExecutor>]
    public async Task Delete_Dimensions_ElementsWithDependenciesDeleted()
    {
        var elementIds = new FilteredElementCollector(_documentFile)
            .WhereElementIsNotElementType()
            .OfCategory(BuiltInCategory.OST_Dimensions)
            .OfClass(typeof(RadialDimension))
            .ToElementIds();

        using var transaction = new Transaction(_documentFile);
        transaction.Start("Delete dimensions");
        var deletedElements = _documentFile.Delete(elementIds);
        transaction.Commit();

        await Assert.That(deletedElements.Count).IsGreaterThanOrEqualTo(elementIds.Count);
    }
}
Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2026.0.1 15 7/18/2025
2025.0.1 9 7/18/2025
2024.0.1 8 7/18/2025
2023.0.1 9 7/18/2025
2022.0.1 8 7/18/2025