2012-10-02 16 views
5

Sto cercando di ottenere piani di test utilizzando l'API TFS.TFS API TestManagementService restituisce sempre null

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

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

La variabile "servizio" restituisce sempre null.

Avete qualche idea, perché?

+0

tfs.GetService (typeof (WorkItemStore)) restituisce l'oggetto del negozio ma ItestManagementService restituisce null – cerezza

risposta

2

Forse stai collegando contro diverse versioni di assembly di riferimento, mescolando le diverse versioni di assemblee di Visual Studio? Esempio:

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

ho avuto lo stesso problema di GetService<ITestManagementService>() tornare sempre nullo, anche quando sarebbe tornato GetService<VersionControlServer>() buona (non null) valore.

La soluzione inviata in MSDN - VersionControlServer always returns null ha funzionato per me: avevo riferimenti ad alcuni assembly v11.0 (VS2012) e v12.0 (VS2013). Cambiando tutti i riferimenti a v11.0 l'ho risolto per me.

4

Provare ad assicurarsi di essere autenticati alla raccolta del progetto team prima di chiamare il comando Ottieni servizio. Questo frammento di codice funziona correttamente per me:

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

ITestManagementService service = tpc.GetService<ITestManagementService>();