Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

A 64-bit test cannot run in a 32-bit process. Specify platform as X64 to force test run in X64 mode on X64 machine.

Visual Studio는 C/C++ 프로젝트 역시 단위 테스트를 (그나마) 쉽게 할 수 있는 기반을 제공합니다. 아래의 문서만 한번 읽어보면 금방 아실 수 있는데요.

Writing Unit tests for C/C++ with the Microsoft Unit Testing Framework for C++
; https://learn.microsoft.com/en-us/visualstudio/test/writing-unit-tests-for-c-cpp

아쉬운 점이라면, 닷넷의 경우 Fakes를 통해 BCL 제어를 할 수 있는 반면 C/C++의 경우에는 Fakes와 같은 기능이 제공되지 않아서 Code Coverage를 높이기 위한 세밀한 제어가 안되는 경우가 많습니다. (물론! ^^ 단위 테스트를 할 수 있다는 것만으로 충분히 가치가 있습니다.)

그런데, x64로 빌드된 DLL을 대상으로 하는 경우, 단위 테스트 실행 시 다음과 같은 오류가 발생할 수 있습니다.

Test Name:  TestMethod1
Test FullName:  CppNativeTest::UnitTest1::TestMethod1
Test Source:    d:\sources\unittest\cppnativetest\unittest1.cpp : line 12
Test Outcome:   Failed
Test Duration:  0:00:00

Result Message: A 64-bit test cannot run in a 32-bit process. Specify platform as X64 to force test run in X64 mode on X64 machine.

메시지에 나타난 그대로, 이유는 x64 용 DLL은 x64로 빌드된 테스트 프로세스에서 로드되어야 하기 때문입니다. 그리고 그 방법도 다음의 문서에서 잘 설명하고 있습니다.

Run a unit test as a 64-bit process
; https://learn.microsoft.com/en-us/visualstudio/test/run-a-unit-test-as-a-64-bit-process

즉, "Test" / "Test Settings" / "Default Processor Architecture" / "X64"로 선택하고 단위 테스트를 진행하면 끝!

x64_unit_test_1.png

참고로, 이 메뉴와 관련한 글을 쓴 적이 있군요. ^^

Visual Studio 단위 테스트 시 DisconnectedContext 예외 발생
; https://www.sysnet.pe.kr/2/0/10962




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 4/29/2023]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 61  62  63  64  65  66  67  68  69  [70]  71  72  73  74  75  ...
NoWriterDateCnt.TitleFile(s)
11882정성태5/2/201914057.NET Framework: 826. (번역글) .NET Internals Cookbook Part 11 - Various C# riddles파일 다운로드1
11881정성태4/28/201914344오류 유형: 532. .NET Core 프로젝트로 마이그레이션 시 "CS0579 Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute" 오류 발생
11880정성태4/25/201911095오류 유형: 531. 이벤트 로그 오류 - Task Scheduling Error: m->NextScheduledSPRetry 1547, m->NextScheduledEvent 1547
11879정성태4/24/201916354.NET Framework: 825. (번역글) .NET Internals Cookbook Part 10 - Threads, Tasks, asynchronous code and others파일 다운로드2
11878정성태4/22/201914323.NET Framework: 824. (번역글) .NET Internals Cookbook Part 9 - Finalizers, queues, card tables and other GC stuff파일 다운로드1
11877정성태4/22/201914211.NET Framework: 823. (번역글) .NET Internals Cookbook Part 8 - C# gotchas파일 다운로드1
11876정성태4/21/201914044.NET Framework: 822. (번역글) .NET Internals Cookbook Part 7 - Word tearing, locking and others파일 다운로드1
11875정성태4/21/201914409오류 유형: 530. Visual Studo에서 .NET Core 프로젝트를 열 때 "One or more errors occurred." 오류 발생
11874정성태4/20/201914416.NET Framework: 821. (번역글) .NET Internals Cookbook Part 6 - Object internals파일 다운로드1
11873정성태4/19/201913381.NET Framework: 820. (번역글) .NET Internals Cookbook Part 5 - Methods, parameters, modifiers파일 다운로드1
11872정성태4/17/201913860.NET Framework: 819. (번역글) .NET Internals Cookbook Part 4 - Type members파일 다운로드1
11871정성태4/16/201913676.NET Framework: 818. (번역글) .NET Internals Cookbook Part 3 - Initialization tricks [3]파일 다운로드1
11870정성태4/16/201911431.NET Framework: 817. Process.Start로 실행한 콘솔 프로그램의 출력 결과를 얻는 방법파일 다운로드1
11869정성태4/15/201915193.NET Framework: 816. (번역글) .NET Internals Cookbook Part 2 - GC-related things [2]파일 다운로드2
11868정성태4/15/201912934.NET Framework: 815. CER(Constrained Execution Region)이란?파일 다운로드1
11867정성태4/15/201911931.NET Framework: 814. Critical Finalizer와 SafeHandle의 사용 의미파일 다운로드1
11866정성태4/9/201915516Windows: 159. 네트워크 공유 폴더(net use)에 대한 인증 정보는 언제까지 유효할까요?
11865정성태4/9/201911238오류 유형: 529. 제어판 - C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools is not accessible.
11864정성태4/9/201910447오류 유형: 528. '...' could be '0': this does not adhere to the specification for the function '...'
11863정성태4/9/201910258디버깅 기술: 127. windbg - .NET x64 EXE의 EntryPoint
11862정성태4/7/201912310개발 환경 구성: 437. .NET EXE의 ASLR 기능을 끄는 방법
11861정성태4/6/201912088디버깅 기술: 126. windbg - .NET x86 CLR2/CLR4 EXE의 EntryPoint
11860정성태4/5/201915338오류 유형: 527. Visual C++ 컴파일 오류 - error C2220: warning treated as error - no 'object' file generated
11859정성태4/4/201912699디버깅 기술: 125. WinDbg로 EXE의 EntryPoint에서 BP 거는 방법
11858정성태3/27/201913152VC++: 129. EXE를 LoadLibrary로 로딩해 PE 헤더에 있는 EntryPoint를 직접 호출하는 방법파일 다운로드1
11857정성태3/26/201912078VC++: 128. strncpy 사용 시 주의 사항(Linux / Windows)
... 61  62  63  64  65  66  67  68  69  [70]  71  72  73  74  75  ...