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

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

This article has been editorially reviewed by Suprotim Agarwal.

Absolutely Awesome Book on C# and .NET

C# and .NET have been around for a very long time, but their constant growth means there’s always more to learn.

We at DotNetCurry are very excited to announce The Absolutely Awesome Book on C# and .NET. This is a 500 pages concise technical eBook available in PDF, ePub (iPad), and Mobi (Kindle).

Organized around concepts, this Book aims to provide a concise, yet solid foundation in C# and .NET, covering C# 6.0, C# 7.0 and .NET Core, with chapters on the latest .NET Core 3.0, .NET Standard and C# 8.0 (final release) too. Use these concepts to deepen your existing knowledge of C# and .NET, to have a solid grasp of the latest in C# and .NET OR to crack your next .NET Interview.

Click here to Explore the Table of Contents or Download Sample Chapters!

What Others Are Reading!
Was this article worth reading? Share it with fellow developers too. Thanks!
Share on LinkedIn
Share on Google+

Author
Gouri is a Trainer and Consultant on Azure DevOps and Azure Development. She has an experience of three decades in software training and consulting. She is a graduate from Pune University and PGDCA from Pune University. Gouri is a Microsoft Most Valuable Professional (MVP)  - Developer Technologies (Azure DevOps), Microsoft Certified Trainer (MCT) and a Microsoft Certified Azure DevOps Engineer Expert. She has conducted over 150 corporate trainings on various Microsoft technologies. She is a speaker with Pune User Group and has conducted sessions on Azure DevOps, SQL Server Business Intelligence and Mobile Application Development. Gouri has written more than 75 articles on Azure DevOps, TFS, SQL Server Business Intelligence and SQL Azure which are published on www.sqlservercurry.com and www.dotnetcurry.com. You can connect with her on LinkedIn.


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