Wednesday, February 28, 2018

Obtaining Results While Test Execution with VSTS Release Management

When you are executing automated functional testing, there could be failures in critical test cases. In such situations, it may be worthless to continue test execution further. However, when you run automated functional test cases thorough VSTS/ TFS, until the full test execution finishes, you would not be able to view the individual test case status. This is a feature considered by Microsoft for VSTS in 2018 Q2 (for on premises TFS 2019) and until that shows up here is small workaround.


image


Result Obtaining Methodology

post1

You can get live test results using the TestCleanup event in a test class.Following code segment retrieves test outcome of each test case and Sends a POST request to the specified Url.


  #region TestCleanup
        [TestCleanup]
        public void Cleanup()
        {
            string testStatus = TestContext.CurrentTestOutcome.ToString();
            long testCaseId = Convert.ToInt64(TestContext.Properties["TestcaseID"]);
            string testStatusRecord = string.Format("{{'TestCaseId':{0},'Status':'{1}'}}",testCaseId, testStatus);
            using (var client = new HttpClient())
            {
                client.PostAsync(
 "Your WebURL",
  new StringContent(testStatusRecord, Encoding.UTF8, "application/json")).Wait();
            }           
            WebDriver.Dispose();
        }
        #endregion


Then you can obtain results while test executing with VSTS\TFS

 LiveView

Further enhancements can be done to above code segment to view the results when executes test through multiple VSTS\TFS release environments.

No comments:

Post a Comment