使用 vstest.consol.exe 到 运行 Moq 单元测试
Using vstest.consol.exe to run Moq unit tests
我在 Visual Studio 2013 年的单元测试中使用了 Moq。我需要 运行 使用 "vstest.console.exe".
命令行中的测试用例
尝试这样做时,出现此错误:
Error: An exception occurred while invoking executor 'executor://mstestadapter/v1': Could not load file or assembly 'Codex.Repository, verion=1.0.0.0, Clture-neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
这是我用来 运行 测试的命令:
vstest.console.exe "C:.../Codex.repository.unittests.dll" /UseVsixVersion /Framework:framework45
当尝试使用“/Tests:”标签单独执行测试用例时,我收到了更详细的错误消息:
Could not load file or assembly 'Moq, Version=4.2.1502.911, Culture-neutral, PublicKeyToken=69f4...' or one of its dependencies. The system cannot fild the file specified.WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: there is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
所以现在我知道原因是在我的测试用例中使用了 Moq。
我该如何解决这个问题?
您需要确保这些依赖项设置为 "Copy Local = True" 这样 vstest.console
就可以在您的测试程序集旁边找到它们。
原来我是用obj文件夹下的单元测试dll文件:
c:\>vstest.console.exe "..\obj\release\unittests.dll"
Visual Studio 将所有依赖的.dll文件放在bin文件夹中所以我改为:
c:\>vstest.console.exe "..\bin\release\unittests.dll"
问题已解决!
我在 Visual Studio 2013 年的单元测试中使用了 Moq。我需要 运行 使用 "vstest.console.exe".
命令行中的测试用例尝试这样做时,出现此错误:
Error: An exception occurred while invoking executor 'executor://mstestadapter/v1': Could not load file or assembly 'Codex.Repository, verion=1.0.0.0, Clture-neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
这是我用来 运行 测试的命令:
vstest.console.exe "C:.../Codex.repository.unittests.dll" /UseVsixVersion /Framework:framework45
当尝试使用“/Tests:”标签单独执行测试用例时,我收到了更详细的错误消息:
Could not load file or assembly 'Moq, Version=4.2.1502.911, Culture-neutral, PublicKeyToken=69f4...' or one of its dependencies. The system cannot fild the file specified.WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: there is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
所以现在我知道原因是在我的测试用例中使用了 Moq。
我该如何解决这个问题?
您需要确保这些依赖项设置为 "Copy Local = True" 这样 vstest.console
就可以在您的测试程序集旁边找到它们。
原来我是用obj文件夹下的单元测试dll文件:
c:\>vstest.console.exe "..\obj\release\unittests.dll"
Visual Studio 将所有依赖的.dll文件放在bin文件夹中所以我改为:
c:\>vstest.console.exe "..\bin\release\unittests.dll"
问题已解决!