Reputation: 23
I use the Assembly.LoadFrom(dll) method to load the assembly with tests and get a list of tests in the project from it
public IEnumerator<string> GetEnumerator()
{
Assembly.LoadFrom(_pathToTestsDll);
var controller = new XunitFrontController(AppDomainSupport.Denied, _pathToTestsDll);
using var visitor = new TestDiscoverySink();
controller.Find(false, visitor, TestFrameworkOptions.ForDiscovery());
visitor.Finished.WaitOne();
var tests = visitor.TestCases.Select(testCase => testCase.DisplayName).ToList();
visitor.Finished.Dispose();
return tests.GetEnumerator();
}
The problem is that after LoadFrom
assembly file is blocked and I can't run it or delete it
Adding shadowCopy: true
to the XunitFrontController
constructor did not help
I have seen such a solution, but it is obsolete Unloading the Assembly loaded with Assembly.LoadFrom()
I looked for an analogue for new versions and if I understood correctly, then this is AssemblyLoadContext
The problem is that it doesn't have a LoadFrom
method that loads the assembly along with the dependencies (or I didn't find it)
How can it be replaced?
Upvotes: 0
Views: 37