0

我已经复制了示例中的代码以从这里收集代码覆盖率的结果,除了我的代码是 vb.net

这是我的代码

Imports Microsoft.VisualStudio.Coverage.Analysis


Module Module1

    Sub Main()
        Using info As CoverageInfo = CoverageInfo.CreateFromFile("C:MyFile\data.coverage")

            Dim lines As New List(Of BlockLineRange)()

            For Each [module] As ICoverageModule In info.Modules

                Dim coverageBuffer As Byte() = [module].GetCoverageBuffer(Nothing)
                Using reader As ISymbolReader = [module].Symbols.CreateReader()

                    Dim methodId As UInteger = 0
                    Dim MethodName As String = ""
                    Dim undecoratedMethodName As String = ""
                    Dim ClassName As String = ""
                    Dim NameSpaceName As String = ""

                    lines.Clear()

                    While reader.GetNextMethod(methodId, MethodName, undecoratedMethodName, ClassName, NameSpaceName, lines)

                        Dim stats As CoverageStatistics = CoverageInfo.GetMethodStatistics(coverageBuffer, lines)
                        Console.WriteLine("Method {0}{1}{2}{3}{4} has:" & NameSpaceName & ClassName & undecoratedMethodName)

                        Console.WriteLine(" blocks covered are {0}", stats.BlocksCovered)
                    End While
                End Using
            Next

        End Using
    End Sub

End Module

当我在线运行它时,CreateFromFile我得到一个ImageNotFoundException

Image File "C:\SomeAddress\MyServer\UnitTest.dll" could not be found 

我已经按照说明将必要的 dll 添加到复制的项目中,另外 2 个作为参考。

4

1 回答 1

0

还有另一个风滚草时刻......

基本上问题是包含我的覆盖文件的文件夹还必须包含在该程序集中使用的所有 dll,在这些程序集中运行测试以创建该对象。

如果您偶然发现此问题,希望这对您有所帮助:)

于 2013-03-04T15:09:58.313 回答