Showing posts with label TFS Rest Api. Show all posts
Showing posts with label TFS Rest Api. Show all posts

Friday, September 8, 2017

TFS Rest Api ile Test Case Oluşturmak



    Yaptığım iş gereği var olan bir Test Case değerini okuyup tekrar oluşturmam gerekti.
 
     $response =  Invoke-RestMethod -Uri "http://tfsaddress/collectionname/_apis/wit/workItems/1"

     if($response.fields.'System.WorkItemType' -eq "Test Case")
     {
     
       $areaPath        = $response.fields.'System.AreaPath'.Replace("\","\\")
       $teamProject     = $response.fields.'System.TeamProject'
       $iterationPath   = $currentIteration
       $workItemType    = $response.fields.'System.WorkItemType'
       $title           = $response.fields.'System.Title'
       $priority        = $response.fields.'Microsoft.VSTS.Common.Priority'
       $automationStatus= $response.fields.'Microsoft.VSTS.TCM.AutomationStatus'
       $steps           = $response.fields.'Microsoft.VSTS.TCM.Steps'.Replace('"',"'")
       $assignToUser    = $assignToUser.Replace("\","\\")

       $json = @"
       [
        {
             "op": "add",
             "path": "/fields/System.Title",
             "value":"$title"
        },

        {
             "op": "add",
             "path": "/fields/System.TeamProject",
             "value":"$teamProject"
        },
       
        {
            "op" : "add",
            "path": "/fields/System.AreaPath",
            "value": "$areaPath"
        },
       
        {
            "op" : "add",
            "path": "/fields/System.WorkItemType",
            "value": "$workItemType"
        },
         
        {
           "op" : "add",
           "path": "/fields/System.IterationPath",
           "value": "$iterationPath"
        },  
     
        {
           "op":"add",
           "path":"/fields/System.State",
           "value":"Design"
        },

        {
           "op" : "add",
           "path": "/fields/Microsoft.VSTS.Common.Priority",
           "value": "$priority"
        },

        {
            "op" : "add",
            "path": "/fields/Microsoft.VSTS.TCM.AutomationStatus",
            "value": "$automationStatus"
        },

        {
           "op" : "add",
           "path": "/fields/Microsoft.VSTS.TCM.Steps",
           "value": "$steps"

        },

        {
           "op" : "add",
           "path": "/fields/System.AssignedTo",
           "value": "$assignToUser"

        },

        ]"
"@

}

   
$result = Invoke-RestMethod  -Uri "http://tfsaddress/collectionname/_apis/wit/workitems/`$Test%20Case?api-version=1.0"
                             -Credential $mycreds
                             -Method Patch
                             -Body  $json
                             -ContentType "application/json-patch+json"




Ürdün

  Çok hızlı bir şekilde karar alıp, harekete geçtiğim bir gezi oldu Ürdün. Nitekim bir pazar günü arkadaşım Firuze ile konuşup, pazartesi...