GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - NeVeSpl/RevitTestLibrary: Proof of concept that it is possible to run and debug unit tests in Visual Studio with remote execution inside Revit.

BranchesTags
Open more actions menu

Latest commit

 

History

16 Commits
16 Commits

Folders and files

NameName
Last commit message
Last commit date
binaries/revit/2023
binaries/revit/2023
 
 
documentation
documentation
 
 
sources/RevitTestLibrary.Demo.MSTestV3
sources/RevitTestLibrary.Demo.MSTestV3
 
 
.gitignore
.gitignore
 
 
.runsettings
.runsettings
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
RevitTestLibrary.sln
RevitTestLibrary.sln
 
 

Repository files navigation

Nuget

Warning Since version v.0.1 the RTL switched to .net 8 (Revit 2025), any further development on .net framework 4.8 (Revit 2023, 2024) is not planned.

RevitTestLibrary (RTL)

Proof of Concept that it is possible to run and debug unit tests in Visual Studio with remote execution inside Revit.

proof-of-concept

Origin

  • RevitTestFramework
  • Revit.TestRunner
  • xUnitRevit

There are three established solutions for unit testing in Revit space, but none of them offers integration with the IDE. This makes them good mostly for detecting regressions, which makes QA happy. We, developers, love and need unit tests for different reasons. There is no better way of writing/understanding a code, than running a small fragment of it in isolation without the need to start the whole (big (and slow)) application once again (aka green arrow development). We need as fast feedback loop as possible.

Red, Green, Refactor, Repeat

Features

  • dlls are not kept locked after conducting a unit test, which means Revit does not have to be closed down in order to recompile dlls
  • full access to the exception Stack Trace with interactive links to source code stack-trace
  • full access to unit test Standard Output
  • unit tests that are run inside Revit context can be mixed with tests that can be run outside of Revit
  • unit tests are run in a special instance of Revit that does not load any addins
  • tests can be run from an IDE, CLI dotnet test or as part of a build pipline

Getting started

  1. Add information about Revit location to .runsettings file. How to use .runsettings on Microsoft learn.
<RunSettings>
  <MSTest> 
    <AssemblyResolution>
      <Directory path="D:\Autodesk\Revit 2025\" includeSubDirectories="false"/>
    </AssemblyResolution>
  </MSTest>
</RunSettings>
  1. Install nuget

https://www.nuget.org/packages/RevitTestLibrary.MSTest

  1. Change test method attribute to [RevitTestMethod] and add one input parameter of type RevitContext
  2. Add the RevitPath attribute [assembly: RevitPath("D:\\Autodesk\\Revit 2025\\Revit.exe")].
using System;
using System.IO;
using Autodesk.Revit.DB;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using RevitTestLibrary;

[assembly: RevitPath("D:\\Autodesk\\Revit 2025\\Revit.exe")]

namespace RevitTestLibrary.Demo.MSTestV3
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod_WriteLine()
        {
            Console.WriteLine("This is a standard test");
        }

        [RevitTestMethod]
        public void Revit_TestMethod_WriteLine(RevitContext context)
        {
            Console.WriteLine("This code is running inside Revit.");
        }
    }
}

Demo

The Demo project is available here: RevitTestLibrary.Demo.MSTestV3

Current limitations

  • works only with : Revit 2025
  • debugging is only available for: Visual Studio 2022
  • theoretically, it can be used with any test framework, but right now only integration with MSTest v2 (>= 3.2.2) is available

About

Proof of concept that it is possible to run and debug unit tests in Visual Studio with remote execution inside Revit.

Topics

rest-apirevit

Resources

Readme
Apache-2.0 license
Activity

Stars

15 stars

Watchers

3 watching

Forks

0 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.