2

所以我用 NUnit 3.2.1 编译了我的测试 dll,我在另一个程序中使用命令“vstest.console.exe”运行,如下所示:

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();

我的问题是我想使用该命令执行我的测试,但在同一目录中没有 nunit.framework.dll。我试图把这个放在 GAC 中,但我仍然遇到以下错误(已经尝试使用 NUnit Adapter 最新版本,仍然相同):

>>> 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.

那么,长话短说,是否可以在没有 nunit.framework.dll 在同一目录中的情况下启动我的 nunit 测试 dll?谢谢

4

1 回答 1

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 ;-)

于 2016-07-11T11:24:49.103 回答