Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Showing posts with label Result in CodedUi Testing. Show all posts
Showing posts with label Result in CodedUi Testing. Show all posts

Write Text Log For Coded Ui Testing in VSTS

How to : Write Text Log For Coded Ui Testing in VSTS

Test Logs are nothing but Results during the Test script run:

Suppose we have a specific scenario of logging into an application ( SignInGlobal in the below discussed case ). In general if we have a successfull Log In we need to maintain a log report that the Scenario has been executed successfully and that the functionality is working fine within the application. Contrarily speaking, in case the scenario/functionality is not working as per the expectation we need the same to be maintained in the log file, so that we can figure out from the Log files after the complete run as to which particular module has failed :

The definition of the below two function calls are available in the UIMap.cs partial class file :

1. SignInGlobal
2. WriteLogs : It is taking two parameters One being the TestC ontext and the other the status message as Failure/Pass.

           try
            {
                this.UIMap.SignInGlobal(TestContext);
                this.UIMap.WriteLogs(TestContext, "Logging Into Aplication Event Success");
            }
            catch (PlaybackFailureException e)
            {
                this.UIMap.WriteLogs(TestContext, "Logging Into Aplication Event Failure");
            }

In UiMap.cs Partial class file keep the below function body defined :

 public void WriteLogs(TestContext varTestcontext, string Status)
        {
            string strAppPath = varTestcontext.DataRow["AppPath"].ToString();
            FileInfo f = new FileInfo(strAppPath + "Results.txt");
            StreamWriter w = f.AppendText();
            w.WriteLine("Module : " + Status + " TimeStamp : " + DateTime.Now.ToString());
            w.Close();
        }


So this particular function namely WriteLogs will append the current status message in the same file .

This is how we can successfully maintain a Log file for the series of events that are happening during the course of script run.