Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get past error "Unable to acquire remote process agent" when using the NUnit Engine

Tags:

c#

nunit

I'm using the NUnit Engine for NUnit 3 to run unit tests from my application. The method for doing so can be found in the answer to this thread "How to run a NUnit test?". This answer is exactly what I need, except when I attempt to run a test I get the following error:

"Unable to acquire remote process agent"

Stack Trace:
[Exception: Unable to acquire remote process agent]
NUnit.Engine.Runners.ProcessRunner.LoadPackage() +530
NUnit.Engine.Runners.AbstractTestRunner.Load() +22
NUnit.Engine.Runners.MasterTestRunner.LoadPackage() +291
NUnit.Engine.Runners.MasterTestRunner.NUnit.Engine.ITestRunner.Run(ITestEventListener listener, TestFilter filter) +56

Any help is greatly appreciated. Thanks.

like image 886
TeeOhDeeDee Avatar asked Oct 26 '25 06:10

TeeOhDeeDee


2 Answers

Passing --inprocess option to nunit3-console.exe solved the problem for me.

like image 119
Sukhman Sandhu Avatar answered Oct 29 '25 09:10

Sukhman Sandhu


If you are going to take this approach, you need to make sure that all of the NUnit assemblies and exe's are in your build directory. In your case, I expect that you are referencing the engine so it is getting included, but the nunit-agent.exe and the other files are likely not present.

That said, why not just use nunit3-console to run your tests, or if you need a self-executing test assembly, use the NUnitLite package. With it, you can run tests as simply as,

using NUnit.Common;
using NUnit.Framework;
using NUnitLite;
using System;
using System.Reflection;

namespace MyProject.Test
{
    public class Program
    {
        public int Main(string[] args)
        {
            return new AutoRun(typeof(Program).GetTypeInfo().Assembly)
                .Execute(args, new ExtendedTextWrapper(Console.Out), Console.In);
        }
    }
}
like image 28
Rob Prouse Avatar answered Oct 29 '25 09:10

Rob Prouse