2

So I've got my dll of test compiled with NUnit 3.2.1 that I run with the command "vstest.console.exe" in another program as follow :

var Args = "/UseVsixExtensions:true" + " " + "\"" + @"D:\path\myDllTestNunit.dll" + "\"" +
                 " " + "/TestAdapterPath:" + "\"" + @"C:\path\NUnit3TestAdapter.3.0.10\lib" + "\"" +
               " " + "/Logger:trx" + " /settings:" + "\"" + @"D:\pathRunsettings\dbci_2016_06_23_10_01_56.runsettings" + "\"";
        var cmdPath = @"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe";

        var proc = new Process();
        proc.StartInfo.FileName = cmdPath;
        proc.StartInfo.Arguments = Args;

        proc.StartInfo.RedirectStandardOutput = true;
        proc.StartInfo.RedirectStandardError = true;
        proc.EnableRaisingEvents = true;
        proc.StartInfo.CreateNoWindow = false;

        proc.ErrorDataReceived += proc_DataReceived;
        proc.OutputDataReceived += proc_DataReceived;
        proc.StartInfo.UseShellExecute = false;
        proc.Start();

        proc.BeginErrorReadLine();
        proc.BeginOutputReadLine();

        proc.WaitForExit();
        Console.ReadLine();

My problem is that I want to execute my test with that command but without having nunit.framework.dll in the same directory. I've tried to put this one in the GAC but i've still got the following error (already tried with NUnit Adapter last version too, still got the same) :

>>> Starting test execution, please wait...
>>> Information: NUnit Adapter 3.0.10.0: Test execution started
>>>
>>> Information: Running all tests in D:\appli\statro\RSS3_BATCHES_TEST\UT\LANCE
MENT_TESTS\RSS3.Batches.Test.Nunit.Tests.dll
>>>
>>> Warning: Dependent Assembly nunit.framework of D:\appli\statro\RSS3_BATCHES_
TEST\UT\LANCEMENT_TESTS\RSS3.Batches.Test.Nunit.Tests.dll not found. Can be igno
red if not a NUnit project.
>>>
>>> Information: NUnit Adapter 3.0.10.0: Test execution complete
>>>
>>> Warning: No test is available in D:\appli\statro\RSS3_BATCHES_TEST\UT\LANCEM
ENT_TESTS\RSS3.Batches.Test.Nunit.Tests.dll. Make sure that installed test disco
verers & executors, platform & framework version settings are appropriate and tr
y again.

So, long story short, is it possible to launch my dll of nunit test without having nunit.framework.dll in the same directory ? Thanks

neow
  • 21
  • 3
  • *Why* do you want to do that? The test assembly will expect to be able to load `nunit.framework.dll`... it's as simple as that. – Jon Skeet Jul 11 '16 at 07:39
  • Well i will have to launch this command on multiple directory with multiple dll of test, and I dont want to install nunit.Framework.dll in each directory in order to launch these tests. So I want to put it somewhere else (tried GAC), but it seems that the references can't find it. – neow Jul 11 '16 at 07:44
  • But how are you building these test assemblies? I'd expect the build process to include all of the dependencies of the test assemblies - including nunit.framework.dll - automatically. – Jon Skeet Jul 11 '16 at 07:47
  • Yes of course my test assembly has a reference to nunit.Framework.dll which is in the GAC, then I build it, and I launch my command on that assembly. But it's impossible to execute this one without having nunit.Framework.dll in the same repository. – neow Jul 11 '16 at 07:53
  • I would remove it from the GAC, and have CopyLocal=true, so that it *does* get copied automatically. Generally speaking, I'd avoid the GAC as much as possible - it was meant to make things simpler, but in the end it's caused more problems IME. – Jon Skeet Jul 11 '16 at 07:54
  • Ok I'll give it a try, I'll come back to tell you if this solution is ok, Thank you very much by the way ! – neow Jul 11 '16 at 08:43
  • Ok I've found another way with our homemade framework thanks to what you said to me there. Thank you, I understand now why GAC is not the solution to everything. – neow Aug 22 '16 at 07:51

1 Answers1

0

The NUnit runners manually load the framework in order to support multiple versions of the framework. For example, NUnit 2 and 3 tests are run by an entirely different runner internally. We also support running tests against multiple versions of the framework in one test run.

NUnit also does not ship with an install that puts the assemblies in the GAC because it does not support multiple copies for different .NET targets. Because of this, the assembly load code has never been tested with the GAC, nor will it be.

The GAC is also difficult for developers on your team who need to manually install the correct version and target of NUnit before they can build. They also need to coordinate version upgrades.

Disk is cheap, use NuGet and allow it to copy in dependencies as was intended. We are all hired to solve business problems, not fight our build tools ;-)

Rob Prouse
  • 22,161
  • 4
  • 69
  • 89
  • Yes of course it would be great to be able to use NuGet, but it's still not suported by the home made Tools that compile my dlls and install them on the server. So I have to find some other ways, and I actually try with the copy local way. Thanks for your answer – neow Jul 11 '16 at 11:54