0

기본적으로 MStest를 사용하여 일련의 코딩 된 UI 테스트를 실행하고 있습니다.코딩 된 Ui 테스트 실행 중 사용자 지정 로그 만들기

테스트가 실행되는 동안 사용자 지정 로그 파일을 쓰려고합니다. 테스트가 지난 경우

는 모든 테스트의 마지막 예를 들어, 내가 바람직 TXT 파일로 나갈 것

이를 "테스트 통과"라는 텍스트 파일에 한 줄을 추가합니다. 그리고 확장으로 나는 이것을 결국 전자 메일로 출력 할 것이지만 지금은 필요하지 않습니다. 각 테스트의 끝에서 기본적인 수준에

내가이

if (this.testContextInstance.CurrentTestOutcome.Equals(true)) 
     { 
      string lines = "Passed."; 
      System.IO.StreamWriter file = new System.IO.StreamWriter("c:\test.txt"); 
      file.WriteLine(lines); 
      file.Close(); 
     } 
     else 
     { 
      string lines = "Failed."; 
      System.IO.StreamWriter file = new System.IO.StreamWriter("c:\test.txt"); 
      file.WriteLine(lines); 
      file.Close(); 
     } 
    } 

을 시도하고 있었다 그러나 나는 완전히 CurrentTestOutcome 방법을 이해하지 않습니다.

현재 파일 출력이 전혀 없습니다.

답변

1

CurrentTestOutcome은 열거 형입니다. http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.testcontext.currenttestoutcome.aspxhttp://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.unittestoutcome.aspx을 참조하십시오. 따라서 질문의 this.testContextInstance.CurrentTestOutcome.Equals(true)이 무엇을 성취하는지 확신 할 수 없습니다.

는 다음과 같은

뭔가 보여 주어야 당신이 원하는 :

string lines = "Failed."; 
System.IO.StreamWriter file = new System.IO.StreamWriter("c:\test.txt"); 
file.WriteLine(this.testContextInstance.CurrentTestOutcome.ToString()); 
file.Close(); 
관련 문제