强制NCover 1.5.8使用V4框架,比如testdriven.net呢? [英] Force NCover 1.5.8 to use v4 framework like testdriven.net does?

查看:236
本文介绍了强制NCover 1.5.8使用V4框架,比如testdriven.net呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要运行的命令行覆盖,但似乎无法得到NCover 1.5.8仪器的code。因为当我运行覆盖测试,TestDriven.net它的作品必须是可能的。差别似乎是TD.NET能够得到NCover使用框架4.0(在日志中得到这个运行时:消息:v4.0.30319 ),但是从在命令行中我不能让它(我得到这个在日志中:消息:V2.0.50727

那么,如何才能让NCover发挥好与NUnit的从命令行,就像它与TD.NET?

解决方案

更​​多的搜索后,我发现这一点:

  

如果你发现这个线程,因为   你正在试图让NCover 1.5.8到   使用.NET 4,然后上班以下   要解决这个错误:

     

打开命令提示符,然后输入   下面的一组   COMPLUS_ProfAPI_ProfilerCompatibilitySetting = EnableV2Profiler

     

这指示.NET 4 CLR加载   .NET Framework 2.0中探查。

     

有关更多信息,请参阅:    http://msdn.microsoft.com/en-us/library/dd778910.aspx

在这里年底>

这似乎解决我的问题。

修改

它并没有解决我的问题真的。现在,它只是允许产生coverage.xml,但它仅包含2.0框架组件,所以才有了.NET 2.0组件异形......

哎呀。回到绘图板...

编辑2

哈利路亚!我已经想通了这一点通过随机使用Google和变化的过程。无论如何,由于一些指针发现这里我能弄清楚,我需要做的是改变运行code中的应用(nunit.console-x86.exe程序在这种情况下)文件不仅迫使.NET Framework的一个特定版本的exe.config加载而且要允许使用的传统的激活策略来。为了削减长话短说我能够解决这样的:

  • 添加到NUnit控制台-x86.exe.config以下部分:

 <结构>
    <启动useLegacyV2RuntimeActivati​​onPolicy =真正的>
        < supportedRuntime版本=v4.0.30319/>
    < /启动>
< /结构>
 

  • 该命令是从启动环境中设置这些:

    设置ProfAPI_ProfilerCompatibilitySetting = EnableV2Profiler
    设置COMPLUS_ProfAPI_ProfilerCompatibilitySetting = EnableV2Profiler
    (不知道两者都是必要的,但是这就是我所做的)

我还添加了一个类似的设置对NCover.Console.Exe.config,但事实证明这是不必要的。

修改3

这是我使用的(请注意,我复制了所有ncover和NUnit和我的测试组件到一个目录中,以简化的东西)在命令行

NCover.Console.exe NUnit控制台-x86.exe程序/framework=4.0.30319 Your.Test.Assembly.dll // x coverage.xml //章

I want to run coverage from the command line, but can't seem to get NCover 1.5.8 to instrument the code. It must be possible as when I run coverage tests with TestDriven.net it works. the difference seems to be that TD.NET is able to get NCover to use framework 4.0 (you get this in the log when it runs : MESSAGE: v4.0.30319) but from the command line I can't make it (I get this in the log : MESSAGE: v2.0.50727)

So how can I make NCover play nice with nunit from the commandline, like it does with TD.NET?

解决方案

after more searching I found this:

If you have found this thread because you are trying to get NCover 1.5.8 to work with .NET 4 then the following should fix this error:

Open a command prompt and type the following set COMPLUS_ProfAPI_ProfilerCompatibilitySetting=EnableV2Profiler

This instructs the .NET 4 CLR to load the .NET Framework 2.0 Profiler.

For more information see: http://msdn.microsoft.com/en-us/library/dd778910.aspx

at the end of the thread here

which seems to solve my problem

EDIT:

it doesn't solve my problem really. Now it just allows the coverage.xml to be generated, but it only contains the v2.0 framework assemblies, so only the .net 2.0 assemblies are profiled....

Grrr. back to the drawing board...

EDIT 2

Hallelujah! I have figured this out by a process of random googling and changing. anyway, due to some pointers found here I was able to figure out that what I needed to do was to alter the exe.config of the application running the code (nunit.console-x86.exe in this case) file to not only force a specific version of the .net framework to be loaded but also to allow the legacy activation policy to be used. To cut a long story short I was able to solve this by:

  • Adding to the nunit-console-x86.exe.config the following section:

<configuration>  
    <startup useLegacyV2RuntimeActivationPolicy="true">  
        <supportedRuntime version="v4.0.30319"/>  
    </startup>  
</configuration>

  • setting these in the environment that the command is launched from:

    set ProfAPI_ProfilerCompatibilitySetting=EnableV2Profiler
    set COMPLUS_ProfAPI_ProfilerCompatibilitySetting=EnableV2Profiler
    (not sure both are necessary, but that's what I did)

I also added a similar setting to the NCover.Console.Exe.config, but it turns out that is unnecessary.

EDIT 3

this is the command line I am using (note that I copied all of ncover and nunit and my test assemblies into one directory to simplify things)

NCover.Console.exe nunit-console-x86.exe /framework=4.0.30319 Your.Test.Assembly.dll //x coverage.xml //reg

这篇关于强制NCover 1.5.8使用V4框架,比如testdriven.net呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆