nunit / nunit/nunit-console

Cannot run .Net Framework Assemblies from nunit.engine.netstandard

Open
#465 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature NetCoreRunner V4
Dominant language
C#
Stars
234
Forks
163
Avg merge
13h 32m
Merged PRs (30d)
25

Description

I have a compiled set of .Net Framework 4.7.1 NUnit3 Tests as a DLL and would like to run them from a .Net Core 2.0 project through the NUnit.Engine.NetStandard.

What I am trying to do is:

  1. Point the TestPackage to the test assembly using:
TestPackage testPackage = new TestPackage(testAssemblyPaths);
  1. Initializing the TestEngine:
_testEngine = new TestEngine();
  1. Creating an instance of the TestRunner and call the Run() method:
using (ITestRunner testRunner = _testEngine.GetRunner(testPackage))
{
    TestFilter categoryTestFilter = builder.GetFilter();

    /* 
    NUnitTestEventMapper and NUnitEventSplitter are custom classes unrelated to this question, 
    the latter of which implements ITestEventListener.
    */
    NUnitTestEventMapper nUnitTestEventMapper = new NUnitTestEventMapper();
    testRunner.Run(new NUnitEventSplitter(subscribers, nUnitTestEventMapper), categoryTestFilter);
}

On Run, I'm getting the following Exception:

Exception Message - 'Could not load file or assembly 'MyTestAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.'

Exception Stack Trace -

   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks, IntPtr ptrLoadContextBinder)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, IntPtr ptrLoadContextBinder)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at NUnit.Engine.Drivers.NUnitNetStandardDriver.Load(String testAssembly, IDictionary`2 settings)
   at NUnit.Engine.Runners.DirectTestRunner.LoadPackage()
   at NUnit.Engine.Runners.DirectTestRunner.EnsurePackageIsLoaded()
   at NUnit.Engine.Runners.DirectTestRunner.RunTests(ITestEventListener listener, TestFilter filter)
   at NUnit.Engine.Runners.TestExecutionTask.Execute()
   at NUnit.Engine.Runners.AggregatingTestRunner.RunTestsSequentially(ITestEventListener listener, TestFilter filter, List`1 results, Boolean disposeRunners)
   at NUnit.Engine.Runners.AggregatingTestRunner.RunTests(ITestEventListener listener, TestFilter filter)
   at NUnit.Engine.Runners.MasterTestRunner.RunTests(ITestEventListener listener, TestFilter filter)
   at NUnit.Engine.Runners.MasterTestRunner.Run(ITestEventListener listener, TestFilter filter)

Should it be possible at all to create a TestPackage pointing to test assemblies using .Net Framework and .Net Core and running everything using a single .Net Standard Engine?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with NUnit.Engine.Drivers.NUnitNetStandardDriver.Load and the DirectTestRunner loading path named in the stack trace. Reproduce the run using a .NET Framework 4.7.1 test assembly from a .NET Core 2.0 host, then determine whether this assembly combination is supported by the .NET Standard engine. Done means the compatibility behavior and any required limitation are clearly established.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.