Skip to content

NUnitTest_Engine: do not attempt to load assemblies from project reference when the context is the ProgramData BHoM folder #445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion NUnit_Engine/NUnitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,16 @@ public abstract class NUnitTest
{

[OneTimeSetUp]
[Description("Loads all assemblies referenced by the derived Test class' project. " +
[Description("Loads all assemblies referenced by the derived Test class' project, when in a Test Explorer context. " +
"This is required to make sure that otherwise lazy-loaded assemblies are loaded upfront, " +
"in order to avoid runtime errors when using dynamic mechanisms like RunExtensionMethod().")]
public void LoadReferencedAssemblies()
{
// If the tests are being run from a process that is based in ProgramData (e.g. BHoMBot),
// this method does not apply, because we assume that all the available assemblies are pre-loaded by such process. Return.
if (AppDomain.CurrentDomain.BaseDirectory.EndsWith(@"ProgramData\BHoM\Assemblies\"))
return;

// Get the referenced assemblies of the Test Project.
var testProjectDir = Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).Parent.Parent.Parent.FullName;
var files = Directory.GetFiles(testProjectDir, "*.csproj");
Expand Down