本文介绍了VS2012单元测试框架始终失败,并显示“调用目标已抛出异常".即使没有用户代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Win8 RTM和最新的VS2012 Professional(下载于2012年11月11日)后,我遇到了一些问题,运行用于Win8 RC/VS2012 RC的单元测试.

after moving to Win8 RTM and latest VS2012 Professional (downloaded 9/11/2012) I had some problem running unit tests that used to work in Win8 RC / VS2012 RC.

我将重现故障所需的步骤简化为以下内容:

I reduced the steps needed to reproduce the failure to the following:

安装最新的VS2012(版本11.0.50727.1 RTMREL)并启动选择文件"->新建项目"

Install latest VS2012 (Version 11.0.50727.1 RTMREL) and launch Select File->New Project

在对话框窗口中,选择模板"->"Visual C#"->"Windows应用商店"->单元测试库(Windows应用商店)",并接受文件名和位置的默认设置.

In the dialog window select Templates->Visual C#->Windows Store->Unit Test Library (Windows Store Apps) and accept the defaults for file names and locations.

在生成的模块中,添加行"Assert.IsTrue(true);".作为测试方法中的唯一代码. (这是可选的;没有添加,就会出现相同的问题.)

In the resulting module add the line "Assert.IsTrue(true);" as the only code in the Test Method. (This is optional; without the addition the same problem exhibits.)

使用测试->运行->所有测试"; (或Debug,出现相同的问题)

Use "Test->Run->All Tests" (or Debug, same problem exhibits)

在测试"输出窗口中观察以下内容:

Observe the following in Tests output window:

 

------发现测试已开始------

------ Discover test started ------

===========发现测试已完成:找到1个(0:00:02.0429028)==========

========== Discover test finished: 1 found (0:00:02.0429028) ==========

------开始运行测试------

------ Run test started ------

创建新的干净布局...

Creating a new clean layout...

 

正在复制文件:总计

Copying files: Total <1 mb to layout...

 

正在注册要从布局运行的应用程序...

Registering the application to run from layout...

 

部署完成.完整包装名称:"8158ae56-4dbd-44ce-a1df-ae4827f6847d_1.0.0.0_neutral__k51y4d8nyn5ce"

Deployment complete. Full package name: "8158ae56-4dbd-44ce-a1df-ae4827f6847d_1.0.0.0_neutral__k51y4d8nyn5ce"

 

调用的目标已引发异常.

Exception has been thrown by the target of an invocation.

===========运行测试完成:0运行(0:00:02.062647)==========

========== Run test finished: 0 run (0:00:02.062647) ==========

-----------

-----------

由于我已经很长一段时间没来(开发Visual Studio了),所以我对自己做错了事感到满意.但是,我不知道它是什么或如何解决.

Since I haven't been at this (dev. w/ Visual Studio that is) for very long, I am comfortable with the idea that I've done something wrong.  However, I don't know what it is or how to solve it.

不幸的是,这种行为很容易在产品的关键区域重现.

And it seems unfortunate that such behavior is so easy to reproduce in a critical area of the product.

感谢您可能提供的帮助

乔尔公园

推荐答案

根据您的描述,您似乎无法在VS2012 Professional中创建和使用单元测试.我个人认为您的VS可能出了一些问题,导致了异常.要解决您的问题,请先尝试修复您的问题 VS看看是否有帮助.

Based on your description, it seems that you can't create and work with unit tests in VS2012 Professional. I personal think that there may be something wrong with your VS which causes the exceptions. To deal with your issue, please first try reparing your VS to see if it helps.

完成后请更新结果.

谢谢.


这篇关于VS2012单元测试框架始终失败,并显示“调用目标已抛出异常".即使没有用户代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 07:27