问题描述
我有一个集成测试(VS术语中的单元"测试,使用TestContext和DeploymentDirectory功能来部署文件),我可以在Visual Studio 2010中运行并通过它,而在Visual Studio 2012中则不能.确切的mstest命令 在Visual Studio 2010命令提示符下,将通过测试,而在Visual Studio 2012中,则通过以下测试将导致失败:
I have an integration test ("unit" test in VS parlance, using the TestContext and DeploymentDirectory features to deploy files) which I can run and pass in Visual Studio 2010, but not in Visual Studio 2012. Literally running the same exact mstest command in the Visual Studio 2010 command prompt results in a passed test, and in Visual Studio 2012 in a failed test with the following result:
当我尝试从VS2012 UI运行它时,它开始运行测试,但是从不显示结果,并出现以下错误:
When I try to run it from the VS2012 UI, it starts to run the test but never shows a result, with the following error:
索引超出了数组的范围.
Index was outside the bounds of the array.
这与VS2012 RTM一起使用,并且在最近发布的CTP1中也有提及.这是我急需解决的问题-我已经购买了具有MSDN订阅和软件保障的VS2012-如何获得有关此问题的支持?似乎更容易 将测试切换到NUnit,然后再执行此调试/支持过程,除非任何人有任何提示.
This is with VS2012 RTM and also noted with the recently-released CTP1. This is an urgent issue for me to fix - I have purchased VS2012 with MSDN subscription and software assurance - how can I get support on this issue? It seems it might be easier to just switch the tests to NUnit than go through this debug/support procedure, unless anyone has any tips.
我还在事件查看器中看到了崩溃提示:
I also see a crash note in Event Viewer:
似乎我可能在VS2012中得到了PathTooLong异常,而在VS2010中却没有.从2012命令提示符运行mstest时,我看到有关此操作的其他警告(针对部署项目),而我在2010年没有看到此警告.
It seems like I might be getting PathTooLong exceptions in VS2012 that I didn't get in VS2010. I see additional warnings regarding this (for deployment items) when running mstest from the 2012 command prompt, that I didn't see for 2010.
关于VS2012部署项目避免PathTooLongExceptions的任何提示吗?对于一个复杂的项目,要超过230个字符似乎很容易.
Any tips for avoiding PathTooLongExceptions with VS2012 deployment items? It seems very easy to exceed 230 characters for a complex project.
推荐答案
感谢您在MSDN论坛中发帖.
根据您的描述,我不能站在您这一边.让我们缩小范围.
我建议您在VS2012中创建一个简单的单元测试,并使用MSTest运行它,以查看是否会发生错误,并确保VS2012中的MSTest正常.
I suggest that you create a simple unit test in VS2012 and run it using MSTest to see if the error will occur and make sure that the MSTest in VS2012 is normal.
您可以在VS IDE中而不是在VS2012中运行MSTest来运行测试,以查看将项目升级到VS2012后项目是否存在问题.
如果在具有VS2012的另一台计算机上运行单元测试,是否还会出现错误?
" System.ArgumentException:无法将类型为"Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapterContext"的对象转换为类型为"Microsoft". VisualStudio.TestTools.UnitTesting.TestContext'..</ "
根据此异常信息,我进行了一些研究,找到了一个具有类似问题的线程,您可以参考:
http://social .msdn.microsoft.com/Forums/zh-CN/vststest/thread/6c735368-ce3d-4e25-8ace-b35e64508ea1/
您可以参考AndersBryhni的回复,并检查VS2012中项目中的UnitTestFramework.dll是否具有正确的版本.如果仍然是v10.0,则可以尝试引用v11.0 dll来检查是否有帮助.
最诚挚的问候,
这篇关于Visual Studio 2012-无法运行在Visual Studio 2010中通过的测试(VSTTExecution异常)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!