title: How to successfully post a generic test result to a VSTS build via API?
body: <p>With the aim of reporting from an external test framework to a VSTS build report - what is the minimum required in a VSTS build definition, to check the ability to post a test result to a test run via the API?</p>
  
  <p>At the moment, I have a minimal proof of concept VSTS build definition containing:</p>
  
  <ul>
  <li>VsTest Test Assemblies   (runs a single MSTest VS test simply to achieve a 60 second delay with System.Threading.Thread.Sleep(60000);) -- However, I do not require Visual Studio tests. Alternatively I tried a powershell wait 60 seconds command without success to simulate a test-wait window.</li>
  </ul>
  
  <p>While the above VSTS build is running, I am trying to post a generic 'test result' in with JSON:</p>
  
  <pre><code> [
  
   {
  
      "testCaseTitle": "myTestCaseTitle",
  
      "automatedTestName": "myAutomatedTestName",
  
      "priority": 1,
  
      "outcome": "Passed"
  
   }
  
  ]
  </code></pre>
  
  <p>To the current test run, at:</p>
  
  <pre><code>https://{instance}/DefaultCollection/{project}/_apis/test/runs/{run}/results?api-version={version}
  </code></pre>
  
  <p>However it still seems during the build test run, the run is not available on the API to post new test results to until the build completes. And once it completes, it is also not available to post results to, with the server response stating:</p>
  
  <p>TestCaseResults cannot be added or updated for a test run which is in Completed state</p>
  
  <p>So, what is the minimum required in a build definition to open up a valid window with which to post generic test results, if this is even possible?  (And can you avoid specifying a particular {run} number, targetting the current run?)  </p>