简体   繁体   English

为什么VS2015中的TestExplorer无法加载Pester模块?

[英]Why TestExplorer in VS2015 failed to load Pester module?

I installed the Powershell Tools for Visual Studio 2015 then I created a tests.ps1 files inside my Powershell project in VS2015. 我为Visual Studio 2015安装了Powershell Tools,然后在VS2015的Powershell项目中创建了一个tests.ps1文件。 the test explorer recognizes the declared test, but when I try to run the test I get this: "Result Message: Failed to load Pester module. The specified module 'Pester' was not loaded because no valid module file was found in any module directory." 测试资源管理器识别声明的测试,但是当我尝试运行测试时,我得到:“结果消息:无法加载Pester模块。未加载指定的模块'Pester',因为在任何模块目录中找不到有效的模块文件“。

VS2015

I discover that I did not have the Pester in my Pc, I download it from GitHub, then I add the folder to the $env:PSModulePath. 我发现我的Pc中没有Pester,我从GitHub下载,然后我将文件夹添加到$ env:PSModulePath。 Powershell identifies the module, but was not able to import it, so I move the folder from its original location to: c:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules\\ Now any console of powershell is able to import the module: ISE, Powershell console, Powershell interactive window in VS2015. Powershell识别模块,但无法导入它,因此我将文件夹从其原始位置移动到:c:\\ WINDOWS \\ system32 \\ WindowsPowerShell \\ v1.0 \\ Modules \\现在任何PowerShell控制台都能导入模块:VS2015中的ISE,Powershell控制台,Powershell交互式窗口。

Then I try to run the test again, I keep getting the same message. 然后我尝试再次运行测试,我一直收到相同的消息。

As I stated in my question: I added the folder with the Pester to the environment variable called PSModulePath , but I added to the end of it. 正如我在我的问题中所述:我将带有Pester的文件夹添加到名为PSModulePath的环境变量中,但我添加到它的末尾。

For some reason the adaptor looks for the path of module only under the first folder in that environment variable. 由于某种原因,适配器仅在该环境变量的第一个文件夹下查找模块的路径。

I changed the order and moved the path to the beginning of the string. 我更改了顺序并将路径移动到字符串的开头。 Voila!! 瞧! it works. 有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM