2009-05-01 4 views
2

MSTest를 사용하여 MFC 코드를 테스트하는 사람이 있습니까?MFC에서 MSTest 사용

관리되는 C++ 테스트 프로젝트를 만들고 그 안에 단위 테스트를 작성할 수 있지만 한 번만 #include <afxwin.h>에 문제가 있습니다. 코드가 컴파일되고 테스트가 실행되면 UI가 중지되고 심볼이로드되지 않습니다. 테스트를 디버깅 할 수도 없습니다. #include을 제거하면 테스트가 성공적으로 실행됩니다. 어떤 아이디어?

/clr을 사용하여 다중 스레드 디버그 (/ mtd)로 컴파일하고 공유 DLL을 통해 MFC를 사용합니다. 정적으로 MFC에 링크를 선택하면 컴파일러 (VSVC9.0)는/clr 및/mtd가 호환되지 않는다고 알려줍니다.

또한 DependencyInput을 테스트에 추가하면 문제가 해결 될 것이라고 생각하십니까? 종속성 입력으로 일부 MFC DLL을 추가하려고했지만 도움이되지 않았습니다. 나는 그것을 잘못 할 수있다.

감사합니다.

답변

0

명령 줄에서 동일합니까?

이 작업을 수행하지 않았습니다. 하지만 정적 창을 만들 수 있습니까? 프로세스 탐색기로 msest 프로세스를 확인하십시오.

1

Visual Studio 2010을 사용하여 직장에서 mfc 코드를 테스트하는 관리되는 C++ 테스트 프로젝트를 만들었습니다.

마법사를 사용하여 C++ 테스트 프로젝트를 만들기 시작했습니다. 그런 다음, 단위 테스트 프로젝트의 구성 속성에서 변경 다음

MFC의> 사용은 "공유 DLL에서 MFC 사용"으로 변경 = 일반 -
  • 일반 -> 공용 언어 런타임 지원 = 공통 언어 지원 "으로 변경 (/ CLR)
  • (디버그 설정에서 전용) 링커 -> 출력 -> 특정 기본이 라이브러리 = STDAFX.H에서 MSVCRT

를 추가 무시 : 나는

다음 한
// 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 

그리고 모든 것이 매력처럼 작동합니다! 작동 여부를 알려주세요.