'這裏是輸出...'OpenCover表示0線覆蓋有MSTEST
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
這是我用
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
命令(我甚至試圖Regsvr32註冊該配置文件和我正在使用XP)
其實我是初學者到Nunit,mstest和opencoverage,我發現樣本單元tes在http://www.nunit.org/index.php?p=quickStart&r=2.4噸情況下如此
** NUnit測試類是如下**
private TestContext testContextInstance;
public TestContext TestContext
{
get { return testContextInstance; }
set { testContextInstance = value; }
}
private int store;
[TestInitialize()]
public void TestFixtureSetUp()
{
store = 1;
}
上述類工作正常使用Nunit和Opencoverage還示出沒有運作得準確的數據,但用MSTEST特定屬性之後同一個類在發佈這個questin之後,我覺得這個方法必須是靜態的,並添加了TestContext參數。所以我按照下面的代碼更改了代碼(,代碼爲),上面的命令工作正常。
MSTest的類
private TestContext testContextInstance;
public TestContext TestContext
{
get { return testContextInstance; }
set { testContextInstance = value; }
}
[ClassInitialize()]
public **static** void ClassInit(**TestContext context**)
{
}
感謝您的答覆是與 – sureshp 2012-03-09 18:52:02
的MSTEST類或許是問題的問題,但即使你的測試不運行,由於測試設置和拆卸,您將獲得覆蓋範圍,並且您的過濾器仍然看起來不正確:) – 2012-03-09 21:45:37