Integrating mstest and coverage reporting in 3rd party Build system with scons

(Tested with VS 2005 only)

I have added mstest.py as new patch, there is a plan to add it to 1.0. But I also added generation of coverage report from mstest run (if coverage was enabled). It does involve running special converter utility and use of external XML python module. So it can not be added in base scons package. I decided to describe steps here.

What will it do?

Why?

How to do it?

Assembly coverage

Assembly

Blocks not covered

% blocks not covered

my1.dll

2419 of 4008

60.3542914171657

my2.dll

125 of 146

85.6164383561644

my3.dll

56 of 74

75.6756756756757

my4.dll

105 of 384

27.34375

my5.dll

401 of 463

86.6090712742981

my6.dll

1605 of 3934

40.7981698017285

my7.dll

287 of 458

62.6637554585153

If you want to modify mstest2xml.exe, there is .Net code for it, also it depends on Microsoft.VisualStudio.Coverage.Analysis.dll, so add it as reference:

using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.CodeCoverage;

namespace mstest2xml
{
    class Program
    {
        static void Main(string[] args)
        {
            String CoveragePath = args[0];
            // Create a coverage info object from the file
            CoverageInfoManager.SymPath = CoveragePath;

            CoverageInfoManager.ExePath = CoveragePath;

            CoverageInfo ci = CoverageInfoManager.CreateInfoFromFile(args[1]);
            // Ask for the DataSet
            // The parameter must be null
            CoverageDS data = ci.BuildDataSet(null);

            // Write to XML
            data.WriteXml(args[2]);
        }
    }
}

Note: for reference I used next article as source for ideas and instructions: joc'c bLog

MsTest (last edited 2008-04-10 14:52:34 by Leanid.Nazdrynau)