VS 2010 - 驱动器映射的单元测试

发布于 2024-10-03 06:46:06 字数 858 浏览 2 评论 0原文

由于我的开发盒上的某些配置,我被迫将代码移至“文档和设置”文件夹。由于我们的 #?*&%$£ “心爱的”perforce VCS 在特定情况下可能会出现长文件路径问题,因此我映射了一个驱动器 (V:) 来指向代码。现在这通常可以工作,但有一个例外:由于某种原因,集成到 VS 中的单元测试运行器无法再运行测试。我专门使用 TestDriven.NET 和 ReSharper 测试运行器进行了尝试。两者都显示出相同的奇怪行为:没有错误,只是不运行测试。

0 次通过,0 次失败,0 次跳过

当我从 C:\Documents... 打开解决方案并使用所述运行程序运行测试时,它有效:

211 次通过,0 次失败,0 次跳过

我首先怀疑是 64 位问题(我们使用的是 Win7 Ultimate x64)。但是测试程序集设置为“任何 CPU”,两个运行程序都可以处理该场景并重定向到适当的 NUnit 可执行文件(...据我所知,如果我错了,请纠正我!)。使用 NUnit GUI 从 C:\ 和 V:\ 打开测试程序集都可以正常工作。

我只能假设这与 VS 中的运行程序在文件路径引用映射驱动器时无法调用测试有关...但这听起来很奇怪,所以我希望你们中的一些人之前见过这个问题并且可以给一些建议。

将其归结为一个问题:
是否有人遇到过 VS 2010 中的 NUnit 测试运行程序无法执行测试的问题,可能是由于解决方案位于映射驱动器上?

Win 7 Ultimate x64
VS 2010 终极版
NUnit 2.5.8
测试驱动.NET 3
锐锐5.1

Due to certain configurations on my dev box I was forced to move my code to the "Documents and Settings" folders. Since our #?*&%$£ "beloved" perforce VCS can have problems with long file paths in specific scenarios, I mapped a drive (V:) to point to the code. This generally works now with one exception: for some reason, unit test runners integrated into VS cannot run tests anymore. I specifically tried this using TestDriven.NET and the ReSharper test runner. Both show the same strange behavior: no errors, tests are only NOT run.

0 Passed, 0 Failed, 0 Skipped

When I open the solution from C:\Documents... and run the tests using said runners, it works:

211 Passed, 0 Failed, 0 Skipped

I first suspected a 64bit issue (we are on Win7 Ultimate x64). But the test assemblies are set to "Any CPU", both runners can handle that scenario and redirect to the appropriate NUnit executables (...as far as I can tell, correct me if I am mistaken!). Opening the test assemblies with the NUnit GUI both from C:\ and V:\ work fine.

I can only assume this has to do with the runners in VS not being able to invoke tests when the file paths refer to a mapped drive...but this sound pretty weird, so I was hoping some of you have seen this problem before and can give some advice.

To boil this down to a question:
Has anyone ever had issues with NUnit test runners in VS 2010 not executing tests, possibly due to the solution being on a mapped drive?

Win 7 Ultimate x64
VS 2010 Ultimate
NUnit 2.5.8
TestDriven.NET 3
ReSharper 5.1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

近箐 2024-10-10 06:46:06

我没试过。但只是一个想法。您可以检查 TestDriven.Net 和 NUnit 的可执行文件的路径吗?您可能还想检查对测试项目的引用。是相对的还是绝对的?

I haven't tried it. But just a thought. Can you check the path of executables for TestDriven.Net as well as NUnit. You might as well want to check the reference to the test project. is it relative or absolute?

仙女 2024-10-10 06:46:06

好的,我们终于找到了解决这个问题的方法。虽然我们并没有真正解决映射 V: 驱动器作为网络驱动器的问题,但如果您使用 SUBST 命令。

这里的区别在于,V: 驱动器被视为网络位置,因为我使用资源管理器菜单中的“映射网络驱动器”创建了映射(我相信这相当于 NET 命令)。当在网络和本地驱动器之间调用程序集时,这可能会导致信任问题。有些人甚至在构建过程中收到如下错误消息

未处理的异常:
系统.安全.安全异常:
该大会不允许部分
值得信赖的来电者。

使用 SUBST 我们的 V: 驱动器指向本地(=受信任)位置,现在我们的测试全部按预期运行

要使用 SUBST 创建映射驱动器,请执行以下操作。此示例将新的虚拟驱动器“V”映射到用户 (= [yourName]) 文件夹中的代码位置:

C:>subst v: C:\Users[yourName]\code

OK, we finally found a way to get around this. While we did not really solve the issue with our mapped V: drive being a network drive, it does work fine if you create the mapped drive using the SUBST command.

The difference here is that the V: drive was treated as a network location since I created the mapping using "map network drive" in the explorer menu (which I believe is equivalent to the NET command). This can lead to trust issues when assemblies are called between network and local drives. Some guys even got error messages during builds along the lines of

Unhandled Exception:
System.Security.SecurityException:
That assembly does not allow partially
trusted callers.

Using SUBST our V: drive points to a local (=trusted) location, and now our tests all run as expected.

To create a mapped drive with SUBST, do the following. This examples maps a new virtual drive "V" to the code location in the users' (= [yourName]) folder:

C:>subst v: C:\Users[yourName]\code

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文