我在Visual Studio 2013的單元測試中使用了Moq。我需要使用「vstest.console.exe」在命令行中運行測試用例。使用vstest.consol.exe運行Moq單元測試
當試圖這樣做,我得到這個錯誤:
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
當試圖individualy執行測試用例使用「/測試:「標籤,我得到了更詳細的錯誤信息:
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].
所以現在我知道原因是在我的te中使用Moq st案件。
我該如何解決這個問題?
如果您還有Visual Studio在同一個節點上,您可以運行一個長時間運行的測試,然後嘗試使用進程資源管理器找出測試dll從哪個文件夾加載。然後使用Vstest.console.exe加載該dll的測試。你將不會再有同樣的錯誤。 –