Enable Tracing Logs with Coded UI Test (CUIT) in Visual Studio 2012
Posted by: Gouri Sohoni
in Category Visual Studio
Abstract: This article explains how to enable tracing logs when executing Coded UI Test in Visual Studio 2012 which will make it easier to find out issues when a Coded UI Test fails
In this article, we will find out how to enable tracing logs when executing with Coded UI Test in Visual Studio 2012. We can use these logs for debugging which will make it easier to find out issues when a Coded UI Test fails.
The tracing can be seen in a html log file. The unfortunate part is that this logging in not available in Coded UI Test by default. We need to change the configuration file in order to enable tracing log. This file depends upon the .NET framework we are working with.
- If the application is targeting .NET Framework 4.0 and there is no App.config file present in the test project, we need to change QTAgent32_40.exe.config.
- If the application is targeting .NET Framework 4.5 and there is no App.config file present in the test project, we need to change QTAgent32.exe.config
In both of the above cases, we need to provide the value of EqtTraceLevel to the level we want
If there is an App.config file present in the test project, we can directly add the configuration entry as
<add name="EqtTraceLevel" value="4" />
This entry needs to be added under configuration node.
Let us discuss where the config file is present and how the tracing log will look like. For this demonstration, I am using framework 4.5 with no App.Config present. The QTAgent32.exe.cofig will be available at drive letter\<Visual Studio Installation folder>\Common7\IDE OR at C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE
Open the file from the specified folder and change the following
There are total 4 levels available as can be seen from the snapshot.
The blog Analyzing Coded UI Tests using Logs discusses about adding the entries for EnableHTMLLogger and EnableSnapshotInfo by setting them to true.
But these 2 entries have been deprecated as described by the post Enable Tracing in CUIT. Now that we have done the necessary configuration setting, what remains is to run the Coded UI Test and find out how the html log gets created.
I have executed one Coded UI Test which is successfully executed and we get the result as follows
Clicking on Output provides the attachment link to the log
The log is shown as below
If we change the EqtTraceLevel to 4 (verbose) we get the complete debug trace
Now let us run a Coded UI Test which fails while execution. I have used a Windows Application action recording for this.
The test fails
The output shows the attachment for log file
The html log looks as the following in 2 parts
Expanding the last action shows
Observe that the png file is also embedded as a part of log file. The log can also be found at %temp%\UITestLogs in the folder of LastRun
Important points: If the log file is not shown with the test execution, ensure that the QTAgent32 process is re-started. We can ensure this by clearing the check box for Keep test execution running between test runs as shown below
That’s it. This is how we enable tracing logs when executing with Coded UI Test in Visual Studio 2012.