2011-02-09 5 views
4

다음 C++ 코드가 있습니다.명령 줄에서 MS 코드 적용 도구를 사용하는 방법?

#include <iostream> 
using namespace std; 

int testfunction(int input) 
{ 
    if (input > 0) { 
     return 1; 
    } 
    else { 
     return 0; 
    } 
} 

int main() 
{ 
    testfunction(-1); 
    testfunction(1); 
} 

나는 악기 실행을, 그 다음 실행

cl /Zi hello.cpp -link /Profile 

를 얻기 위해 컴파일하고 .coverage 바이너리를 생성합니다.

vsinstr -coverage hello.exe 
start vsperfmon -coverage -output:mytestrun.coverage 
vsperfcmd -shutdown 

VS2010에서 커버리지 파일을 열면 그 결과에는 아무 것도 없습니다.

enter image description here

무엇이 잘못 될 수 있는가? this post의 안내를 따랐습니다. 3 단계를 실행하면

  1. > vsinstr /coverage hello.exe
  2. > start vsperfmon /coverage /output:mytestrun.coverage
  3. > hello.exe
  4. > vsperfcmd /shutdown

, 당신은 몇 가지를 볼 수 : 모니터가 시작된 후

답변

8

당신은 프로그램을 실행해야 hello.exe가 시작된 vsperfmon.exe의 알림

여러 번의 테스트 실행을 계획하는 경우 2 ~ 4 단계 만 수행하면됩니다. 즉, 빌드 한 후 바이너리 (1 단계)를 한 번만 계측하면됩니다.

+0

잼. 왜 MS는 이것을 쉽게 문서화 할 수 없었는가? https://msdn.microsoft.com/en-us/library/dd299398(v=vs.90).aspx – granadaCoder

+1

향후 독자를 위해 ........ 여기에 여러 개의 .coverage 파일을 만드는 대체 솔루션이 있습니다. http://stackoverflow.com/questions/415562/mstest-code-coverage/37005493#37005493 – granadaCoder

관련 문제