Free TestComplete Log Viewer Utility From Motoo Yasui
  November 29, 2005

Motoo Yasui has created a free, open source log viewer for TestComplete log files, here is his description:

Introducing: TCLogViewer

TCLogViewer is a stand-alone log viewer for TestComplete and TestExecute.

When using TestExecute to distribute the test scripts, it became
rather obvious that we needed a way to view the generated log quickly
and efficiently, without installing TestComplete.  The only other
way to view log files was to use Internet Explorer, which was very slow
to load a log file.  TCLogViewer was created to fill that gap.

Download TCLogViewer (C# source included)


1. First and most importantly, it loads a log file fast, without the need of TestComplete installation.

2. It does only one thing: reads TestComplete and TestExecute
log files.  Therefore, the file size is very small, making it easy
to distribute.

3. It allows multiple log files to be opened at the same time.  This allows you to compare two or more logs.

4. We wanted a way to differentiate between a regular information
message and a test, and a script error and a test failure.  “Test
Passed”, “Test Failed”, and “Visual Test” is introduced in addition to
standard Info, Error, Warning, and Image.  More on this later in
the document.

5. I found viewing a large image (i.e., full screen captures) on
TestComplete’s log viewer awkward.  In our log, we have image
captures for almost all steps, which allow us to follow each action and
result by going through the log entries one by one.  We needed a
better way to browse the images.  The image panel is located at
the lower-right corner.  Images can be dragged around inside the
panel and resized easily.

6. To allow more flexible way of viewing a log entry, the extended
description and/or the image can be hidden or resized. 
Furthermore, the extended description can be undocked and moved around.

7. Filter allows quick view of a particular message type by listing the desired log message type.

System Requirement:

· Tested on Windows XP only.  Most likely, it runs fine on Windows 2003 and Windows 2000.

· .NET Framework 1.1 or newer.


The viewer will NOT run from a network drive.  Simply copy
TCLogViewer.exe over to anywhere on your local drive after un-packaging.

"Test Passed", "Test Failed", and "Visual Test"

When you see the log properties in the viewer, you might notice log
status in addition to standard Info, Error, and Warning. ("Test
Passed", "Test Failed", and "Visual Test") These are something I
thought would be useful in reporting the test results; I wanted a way
to differentiate a regular Info from a test passing, and regular script
error from test error. These log status are treated like other TC
built-in ones in the log viewer. They have their own icon, etc. You
are, of course, free not to use this feature.  The following
describes the specific syntax for each status:

"Test Passed" - Use it to indicate that your test has passed. It is displayed with a green check mark icon.

To indicate this status, end the log description with "< PASSED >".


Log.Picture(Sys.Screen(), "String matching test < PASSED >", "extended description");

"Test Failed" - Use it to indicate that your test has failed. It'll be displayed with a red "X" icon.

Because I wanted to attach image to it and still indicate the error
in TestComplete’s log viewer, I decided to use the node. Create the
node in the following sequence to use “Test Failed” status. These lines
are condensed into a single line when viewing in TCLogViewer for a
clean, organized look.

Log.CreateNode("description < FAILED >", "extended description");

Log.Picture(Sys.Screen(), "Image capture at the failed instance.");

Log.Error("TEST FAILED", "");




"Visual Test" - When testing in black-box, there
are some object which cannot be accessed directly. This takes image
capture and helps making it apparent that it needs to be visually
verified. The line is displayed with yellow "?" mark.

To use, start the Log.Picture() description with "VISUAL TEST"


Log.Picture(Sys.Screen(), "VISUAL TEST: Verify that string has 4 characters", "extended description");

Missing Features:

There are some features that are available in TC's built-in log
viewer, but not in TCLogViewer.  They were left out because of
lack of time and the needs for our purposes.  I am listing them
here for your convenience.

1. Log.File()

At the moment, any Log.File() entry would be treated just like Log.Message().

2. Priority

This has been sort of implemented, but it’s only visible on the
status bar at the bottom.  The built-in TreeView class in .NET
Framework 1.1 does not allow multi-column tree view.  This may be
addressed in future, given the right component available to us in
future, maybe in .NET Framework 2.0 or any freely available 3rd party component.

3. “Master” Log File Viewer

TCLogViewer does not include a way of viewing the “master” log file,
which summarizes the result of test and provides like to the individual
log.  This was out of the scope of this project.  Maybe some
one can create one.  It can then execute TCLogViewer to view the
individual log file.  TCLogViewer takes a log file name by its
parameter to directly open it.

TCLogViewer Code Overview:

TCLogViewer opens a XML log file, generated by TestComplete and
TestExecute.  It then parses the file and translates it into
viewable form in the TreeView control, available in .NET Framework 1.1.

The most important part of the code is this parsing.  The rest
of code is for displaying the parsed log in user-friendly manner.

.NET Frame work supplies us with several means to read XML files.
 I chose to use XMLTextReader.  XMLTextReader is the fastest
XML reader class available in .NET.  Its downside is that I can
only read forward and that I cannot write and read at the same
time.  I considered the speed of reading a file being the
priority, and I have no need to edit the file.  Also to make it
efficient, each line is formatted into tree nodes (with icon, color,
and font formatting), and placed on the TreeView control, without being
stored in memory at any point.


Parsing and Rebuilding The Node Structure in ReadXML() Method:

The parsing of an XML file is done inside a private method,
ReadXML() in the LogViewer class.  The method parses an XML file
in the following steps:

1. Open an XML file in Figure out the text encoding

2. Open an XML file using XMLTextReader

3. Skip a line

I found it interesting that Microsoft’s XML reader fails unless
this line is skipped, considering that the file can be read by Internet
Explore (though very slow).  The line being skipped is a second
line in an XML file and looks like this:

<?xml:stylesheet type="text/xsl" href="TestName_Result1.xsl"?>

4. Read each log entry in the XML file, one by one, in a loop

This is where each line is processed into nodes in TreeView.  A
log entry is surrounded by <Record>…</Record> tags. 
Inside the <Record> tag, there are 15 different data, stored in
tags, <F0> through <F15>, as described below:

<F0> - Line Number

<F1> - Log Type

<F2> - Description

<F3> - Extended Description

<F4> - Execution Date and Time

<F5> - Priority

<F6> - Skipped

<F7> - Image Path

<F8> - Font Color

<F9> - Font Style

<F10> - Background Color

<F11> - Skipped

<F12> - Skipped

<F13> - Skipped

<F14> - Skipped

<F15> - Branch Index

The color, used in the Font Color and the Background Color, needed
some processing because it is in different format than what .NET
expected.  .NET expects the code to be in red, green, then blue,
while the color code in TestComplete log file seems to be blue first,
then green and red.

The other notable element is the Branch Index in <F15>. 
This is what determines the depth of node, thus this value is essential
in re-building the nodes as intended.  To recreate the node
structures, the Branch Index of the entry being read, and the index
from an entry right before are needed.  Therefore, inside the
loop, information about two entries is always kept.

The Branch Index numbers seem to be random numbers, with the following rules:

A. The same index indicates that the nodes are at same depth from the root

B. An entry with smaller index is always closer to the root

C. If the index is greater than one prior, that entry is a new node under the prior entry

Once an entry is read and placed in TreeView, it is formatted
with appropriate icon, color, and font style.  It also handles the
formatting for the special log type (“Test Passed”, “Test Failed”, and
“Visual Test”) as described in this document.

The process is repeated for each entry in the log file.

5. And finally, close the XML file


TCLogViewer is free and open source. Feel free to use and
modify it according to the license included. Please share
any bug fixes or improvements, thanks. 

Download TCLogViewer (C# source included)

Developed by:

Motoo Yasui,

OnDemand Software, A Division of Global Knowledge