Disabling the debug trace output in Coded UI Tests

January 24th, 2011

The Coded UI tests in Visual Studio 2010 are pretty cool. For the last few months I’ve been using the framework to completely automate a sophisticated web application, with lots of drag and drop and crazy design surfaces.

But the test details page has always looked a little verbose. The default Debug trace is full of so much stuff that I find it completely unusable, and what it does have is barely legible anyway. So usually I just collapse the section and move on to my own less verbose logging and the stack trace.

Unfortunately all this information comes at a bit of a price and I have seen machines run into the good ol’ OutOfMemoryException more than once while working with the log. So to eliminate that cause from the list of possible culprits I hit the net and went searching for how to disable the debug trace in Coded UI Tests.

Unfortunately I didn’t find much (other than how to enable, and usually by editing the test agent configuration). I wanted to find a solution that I could add to my solution (damn overloaded words) that would just work no matter what machine I ran the tests on. Fortunately it was really easy. I just added an App.config file with the following:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.diagnostics>
    <switches>
      <add name="EqtTraceLevel" value="0" />
    </switches>
  </system.diagnostics>
</configuration>

It did the trick and it is making my life a whole lot easier. Hopefully it helps someone else too. (You could also try other values for the level, but I’m an all or nothing kind of guy).