質問

'here is output...'

Loading C:\TEMP\BankDemo_mstest\Test_BankDemo\bin\Debug\Test_BankDemo.dll...
Starting execution...

Results               Top Level Tests
-------               ---------------
Error                 Test.BankDemo.AccountTest.CreditTest
Error                 Test.BankDemo.AccountTest.DebitTest
Error                 Test.BankDemo.AccountTest.FreezeTest
0/3 test(s) Passed, 3 Error

Summary
-------
Test Run Error.
     Error  3
     --------
     Total  3

This is the command I used

OpenCover\OpenCover.Console.exe -register:user 
-output:"Codecoverage.xml" 
-mergebyhash 
-target:"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe" 
targetargs:"/testcontainer:
"C:\TEMP\BankDemo_mstest\Test_BankDemo\bin\Debug\Test_BankDemo.dll" 
/noisolation" 
-filter:"-[Bank.*]* +[Bank*]* +[Bank.Accounts*]* -[Test.BankDemo*]*"

ReportGenerator\bin\ReportGenerator.exe Codecoverage.xml  Coverage HTML

(I have even tried regsvr32 to register the profile and I am using XP)
actually I am beginner to Nunit,mstest and opencoverage and I found sample Unit test case at http://www.nunit.org/index.php?p=quickStart&r=2.4 so
** Nunit test class is as below**

private TestContext testContextInstance;  
public TestContext TestContext  
{  
    get { return testContextInstance; }  
    set { testContextInstance = value; }  
}  
private int store;  
[TestInitialize()]  
public void TestFixtureSetUp()  
{  
    store = 1;   
}  

the above class works fine with Nunit and Opencoverage also showing accurate data but same class after replacing mstest specific attributes didn't worked so after posting this questin I figured it that this method has to be static and added TestContext argument. so I made code changes(in bold) as below and above command worked fine.

MSTest class

private TestContext testContextInstance;  
public TestContext TestContext  
{  
    get { return testContextInstance; }  
    set { testContextInstance = value; }  
}  
[ClassInitialize()]  
public **static**  void ClassInit(**TestContext context**)  
{  
}  
役に立ちましたか?

解決

Your tests aren't failing -- they're erroring, meaning there appears to be a problem compiling the test project. It stands to reason that you'll get no coverage if the tests cannot be built and executed.

他のヒント

2 reasons could be for this however I suspect your filters are wrong, as described in the usage the filters are

(+/-)[assembly/module filter]namespace.typefilter

and exclusion filters take precedence over inclusion filters

So your -[Bank.*]* is excluding types before the +[Bank.Accounts*]* (and probably +[Bank*]*) can take effect. As the default filter +[*]* is only added if you have no other extra filters, other than the default ones, then you should only need to add filters for the modules you wish to profile i.e. +[Bank.*]*

If you open up the XML output then if a class is filtered out then a reason is supplied via the skippedDueTo attribute.

The other reason could be due to missing PDB files not in the folder of the assembly (some test harnesses copy assemblies to other folders - but I see you are using the /noisolation switch - so this shouldn't be it)

Please feel free to discuss or if you think there is a big raise the issue on the OpenCover GitHub site

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top