Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 2008 在MFC中使用MSTest_Visual Studio 2008_Unit Testing_Mstest - Fatal编程技术网

Visual studio 2008 在MFC中使用MSTest

Visual studio 2008 在MFC中使用MSTest,visual-studio-2008,unit-testing,mstest,Visual Studio 2008,Unit Testing,Mstest,是否有人使用MSTest测试MFC代码 我创建了一个托管C++测试项目,可以在其中编写单元测试,但是一旦我的代码>包含了< /C> >,那么我就有问题了。代码将被编译,当它开始运行测试时,UI将挂起,并且不会加载任何符号。您也不能调试测试。如果我删除#include,那么测试将成功运行。有什么想法吗 它使用带有多线程调试(/mtd)的/clr进行编译,并通过共享dll使用MFC。如果我选择静态链接到MFC,那么编译器(VSVC9.0)会告诉我/clr和/mtd不兼容 另外,您认为将Depende

是否有人使用MSTest测试MFC代码

我创建了一个托管C++测试项目,可以在其中编写单元测试,但是一旦我的代码>包含了< /C> >,那么我就有问题了。代码将被编译,当它开始运行测试时,UI将挂起,并且不会加载任何符号。您也不能调试测试。如果我删除

#include
,那么测试将成功运行。有什么想法吗

它使用带有多线程调试(/mtd)的/clr进行编译,并通过共享dll使用MFC。如果我选择静态链接到MFC,那么编译器(VSVC9.0)会告诉我/clr和/mtd不兼容

另外,您认为将DependencyInput添加到测试中会解决这个问题吗?我尝试过添加一些MFC DLL作为依赖项输入,但没有帮助。不过我可能做错了


谢谢。

从命令行看是否相同


我没有这样做。但是可以创建一个静态窗口吗?使用MealExplorer检查.MS/Process。

< P>工作,使用VisualStudio 2010,我们成功创建了一个托管C++测试项目来测试MFC代码。p> <>我们开始使用向导创建C++测试项目。然后,在单元测试项目的配置属性中,更改以下内容:

  • 常规->使用MFC=更改为“在共享DLL中使用MFC”
  • 常规->公共语言运行时支持=更改为“公共语言支持(/clr)”
  • (仅在调试配置中)链接器->输出->忽略特定的默认库=添加MSVCRT
在stdafx.h:我有以下几点

// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER              // Allow use of features specific to Windows XP or later.
#define WINVER 0x0501       // Change this to the appropriate value to target other versions of Windows.
#endif

#ifndef _WIN32_WINNT        // Allow use of features specific to Windows XP or later.                   
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif                      

#ifndef _WIN32_IE           // Allow use of features specific to IE 6.0 or later.
#define _WIN32_IE 0x0600    // Change this to the appropriate value to target other versions of IE.
#endif

#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions

#ifndef _AFX_NO_OLE_SUPPORT
#include <afxole.h>         // MFC OLE classes
#include <afxodlgs.h>       // MFC OLE dialog classes
#include <afxdisp.h>        // MFC Automation classes
#endif // _AFX_NO_OLE_SUPPORT

#ifndef _AFX_NO_DB_SUPPORT
#include <afxdb.h>          // MFC ODBC database classes
#endif // _AFX_NO_DB_SUPPORT

#include <afxdtctl.h>       // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>         // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
//如果必须在下面指定的平台之前以平台为目标,请修改以下定义。
//有关不同平台对应值的最新信息,请参阅MSDN。
#ifndef WINVER//允许使用特定于Windows XP或更高版本的功能。
#定义WINVER 0x0501//将其更改为适当的值,以针对其他版本的Windows。
#恩迪夫
#ifndef\u WIN32\u WINNT//允许使用特定于Windows XP或更高版本的功能。
#定义_WIN32\u WINNT 0x0501//将其更改为适当的值,以针对其他版本的Windows。
#恩迪夫
#ifndef\u WIN32\u IE//允许使用特定于IE 6.0或更高版本的功能。
#定义_WIN32_IE 0x0600//将其更改为适当的值,以针对IE的其他版本。
#恩迪夫
#包括//MFC核心和标准组件
#包括//MFC扩展
#ifndef\u AFX\u无支持
#包含//MFC OLE类
#包含//MFC OLE对话框类
#包括//MFC自动化类
#endif/\u AFX\u无OLE\u支持
#ifndef\u AFX\u无DB\u支持
#包括//MFC ODBC数据库类
#endif/\u AFX\u无数据库\u支持
#包括//对Internet Explorer 4通用控件的MFC支持
#ifndef\u AFX\u无AFXCMN\u支持
#包括//对Windows通用控件的MFC支持
#endif/\u AFX\u不支持AFXCMN\u
一切都像一个魔咒! 让我知道它是否适合你