none
$project.TestPlans is missing in powershell?

    Question

  • Using VS2010, in C#, I get a ITestManagementService project, and execute project.TestPlans.Query("SELECT * FROM TestPlan"));

    However, in powershell $project.TestPlans is null.  What am I doing wrong?

    thx!

    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.TestManagement.Client")
    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Client")


    [psobject] $tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($tfsServerUri)
    [psobject] $tms = $tfs.GetService([Microsoft.TeamFoundation.TestManagement.Client.ITestManagementService]);
    [psobject] $project = $tms.GetTeamProject($tfsProjectName)
    [psobject] $testplans = [Microsoft.TeamFoundation.TestManagement.Client.ITestManagementTeamProject]$project.TestPlans

    • Edited by Brian C Williams Monday, April 26, 2010 11:09 PM added my code
    • Moved by Edwer Fang Tuesday, April 27, 2010 5:25 AM (From:Visual Studio Team System - Testing)
    Monday, April 26, 2010 11:05 PM

Answers

  • Folks,

    This is happening because of following bug in powershell.

    https://connect.microsoft.com/feedback/ViewFeedback.aspx?FeedbackID=249840&SiteID=99

    And as mentioned in the above bug, you can use reflection or the Get-Interface method to access it.

    Here is the poweshell snippet I used to make it work.

    [Microsoft.TeamFoundation.TestManagement.Client.ITestManagementTeamProject] $tcmProject = $tcmService.GetTeamProject($projectName);

    $testPlansProperty = [Microsoft.TeamFoundation.TestManagement.Client.ITestManagementTeamProject].GetProperty("TestPlans").GetGetMethod();
    $testPlans = $testPlansProperty.Invoke($tcmProject, "instance,public", $null, $null, $null);

    Regards

    Aseem Bansal

    Monday, November 12, 2012 11:05 AM

All replies

  • Hello,

    I am moving this post to Testing with Visual Studio Test Manager (MTM) Forum so you can get better and quicker response as there are more experts on it.

    Thanks for your understanding.


    Edwer Fang [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
    Tuesday, April 27, 2010 5:24 AM
  • I have the same problem.
    Friday, February 18, 2011 6:22 PM
  • Same problem here.  

    Thursday, May 3, 2012 2:29 PM
  • I belive you need to explicitly load some assemblies. Try Microsoft.TeamFoundation.TestManagement.Client.
    Thursday, May 3, 2012 3:28 PM
  • Folks,

    This is happening because of following bug in powershell.

    https://connect.microsoft.com/feedback/ViewFeedback.aspx?FeedbackID=249840&SiteID=99

    And as mentioned in the above bug, you can use reflection or the Get-Interface method to access it.

    Here is the poweshell snippet I used to make it work.

    [Microsoft.TeamFoundation.TestManagement.Client.ITestManagementTeamProject] $tcmProject = $tcmService.GetTeamProject($projectName);

    $testPlansProperty = [Microsoft.TeamFoundation.TestManagement.Client.ITestManagementTeamProject].GetProperty("TestPlans").GetGetMethod();
    $testPlans = $testPlansProperty.Invoke($tcmProject, "instance,public", $null, $null, $null);

    Regards

    Aseem Bansal

    Monday, November 12, 2012 11:05 AM
  • Is there a way to Add TestResults from PowerShell. I am executing JavaScript Unit Test on the Build Server using Grunt. Grunt produces the XML Result file for the JavaScript Test. I wanted to push those results in Test and display them as under Heading JAvaScript Unit Test.

    SO Essentially i wan to just push the results into tfs testresult.

    Thursday, May 8, 2014 10:12 PM
  • There are lot of code snippets on this link, see whether you find any of them useful for your scenario.

    http://blogs.msdn.com/b/aseemb/archive/2012/08/07/code-snippets-on-test-management-apis.aspx

    I just glanced at the snippets and found that you might be looking for the last code snippet where it is showing how to create test run/result and mark them pass/fail. Since the code snippet is in c#, it should be pretty straight-forward for you to port it to powershell.

    Regards

    Aseem Bansal

    Monday, May 12, 2014 11:10 AM