2012-10-02 4 views
5

TFS API를 사용하여 테스트 계획을 세우려고합니다.TFS API TestManagementService는 항상 null을 반환합니다.

TfsTeamProjectCollection tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://xxxxxxx:8080/tfs/DefaultCollection")); 

var service = (ITestManagementService)tfs.GetService(typeof(ITestManagementService)); 

변수 "service"는 항상 null을 반환합니다.

이유가 있습니까?

+0

tfs.GetService (typeof (WorkItemStore))는 저장소 개체를 반환하지만 ItestManagementService는 null을 반환합니다. – cerezza

답변

2

은 아마 당신은 Visual Studio를 어셈블리의 다른 버전을 혼합, 참조 어셈블리의 다른 버전에 연결하는거야? 예 :

  • Microsoft.TeamFoundation.Client V11.0 (2012 VS)
  • Microsoft.TeamFoundation.TestManagement.Client v12.0 (2013 VS)

나는 GetService<VersionControlServer>() 좋은 반환하는 경우에도 항상 null을 반환 GetService<ITestManagementService>() 같은 문제가 있었다 (null이 아닌) 값.

솔루션은 MSDN - VersionControlServer always returns null에 게시되었습니다. 일부 v11.0 (VS2012) 및 v12.0 (VS2013) 어셈블리에 대한 참조가있었습니다. v11.0에 대한 모든 참조를 변경하면 문제가 해결되었습니다.

4

서비스 가져 오기 명령을 호출하기 전에 팀 프로젝트 컬렉션에 대한 인증을 받았는지 확인하십시오. 이 코드는 나를 위해 올바르게 작동 :

TfsTeamProjectCollection tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("https://tfs.companyname.com/tfs/DefaultCollection")); 
tpc.EnsureAuthenticated(); 

ITestManagementService service = tpc.GetService<ITestManagementService>(); 
관련 문제