DotNetCurry Logo

Enable Tracing Logs with Coded UI Test (CUIT) in Visual Studio 2012

Posted by: Gouri Sohoni , on 4/10/2013, in Category Visual Studio, VSTS & TFS
Views: 35145
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.

OR

- 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

<system.diagnostics>
<switches>
<add name="EqtTraceLevel" value="4" />
</switches>
</system.diagnostics>

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

trace-level

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.

enable-html-logger

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

execute-cuit

Clicking on Output provides the attachment link to the log

attachment

The log is shown as below

cuit-test-log

If we change the EqtTraceLevel to 4 (verbose) we get the complete debug trace

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

failed-test

The output shows the attachment for log file

log-attachment

The html log looks as the following in 2 parts

coded-ui-test-log

Expanding the last action shows

action-failed

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

test-execution-actions

That’s it. This is how we enable tracing logs when executing with Coded UI Test in Visual Studio 2012.

Was this article worth reading? Share it with fellow developers too. Thanks!
Share on Google+
Further Reading - Articles You May Like!
Author
Gouri Sohoni is a Trainer and Consultant for over two decades. She specializes in Visual Studio - Application Lifecycle Management (ALM) and Team Foundation Server (TFS). She is a Microsoft MVP in VS ALM, MCSD (VS ALM) and has conducted several corporate trainings and consulting assignments. She has also created various products that extend the capability of Team Foundation Server.


Page copy protected against web site content infringement 	by Copyscape




Feedback - Leave us some adulation, criticism and everything in between!
Comment posted by KT on Wednesday, July 31, 2013 5:06 AM
Nice article