Not sure what I am doing wrong while trying to use opencover. I am able to generate reports by running it against executable console apps however whenever I try to run it against actual test code I am in no luck. I have mstest and opencover added to system path.
The library code:
namespace SimpleLibrary
{
public class SimpleClass
{
public string HelloWorld()
{
return "HelloWorld!";
}
}
}
Test Code :
namespace SimpleTestProj
{
[TestClass()]
public class SimpleClassTest
{
[TestMethod()]
public void HelloWorldTest()
{
SimpleClass target = new SimpleClass();
string expected = "HelloWorld!";
string actual;
actual = target.HelloWorld();
Assert.AreEqual(expected, actual);
}
}
}
With '-register:user' flag the tests fail for some reason:
C:\nickolay\SimpleLibrary\SimpleTestProj\bin\Release>opencover.console.exe -output:"coverage.xml" -mergebyhash -target:
"mstest.exe" -targetdir:"C:\nickolay\SimpleLibrary\SimpleTestProj\bin\Release" -targetargs:"/testcontainer:SimpleTestPro
j.dll" -filter:+[*]* -register:user
Executing: C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe
Microsoft (R) Test Execution Command Line Tool Version 10.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.
Loading SimpleTestProj.dll...
Starting execution...
Results Top Level Tests
------- ---------------
Failed SimpleTestProj.SimpleClassTest.HelloWorldTest
0/1 test(s) Passed, 1 Failed
Summary
-------
Test Run Failed.
Failed 1
---------
Total 1
Results file: C:\nickolay\SimpleLibrary\SimpleTestProj\bin\Release\TestResults\labuser.SDKiosk_SAN-D5RHRCK1 2013-07-24
21_04_25.trx
Test Settings: Default Test Settings
Committing...
Visited Classes 0 of 2 (0)
Visited Methods 0 of 4 (0)
Visited Points 0 of 9 (0)
Visited Branches 0 of 4 (0)
==== Alternative Results (includes all methods including those without corresponding source) ====
Alternative Visited Classes 0 of 2 (0)
Alternative Visited Methods 0 of 6 (0)
Without '-register:user' it says that assemblies were not instrumented:
C:\nickolay\SimpleLibrary\SimpleTestProj\bin\Release>opencover.console.exe -output:"coverage.xml" -mergebyhash -target:
"mstest.exe" -targetdir:"C:\nickolay\SimpleLibrary\SimpleTestProj\bin\Release" -targetargs:"/testcontainer:SimpleTestPro
j.dll" -filter:+[*]*
Executing: C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe
Microsoft (R) Test Execution Command Line Tool Version 10.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.
Loading SimpleTestProj.dll...
Starting execution...
Results Top Level Tests
------- ---------------
Passed SimpleTestProj.SimpleClassTest.HelloWorldTest
1/1 test(s) Passed
Summary
-------
Test Run Completed.
Passed 1
---------
Total 1
Results file: C:\nickolay\SimpleLibrary\SimpleTestProj\bin\Release\TestResults\labuser.SDKiosk_SAN-D5RHRCK1 2013-07-24
21_08_43.trx
Test Settings: Default Test Settings
Committing...
No results - no assemblies that matched the supplied filter were instrumented
this could be due to missing PDBs for the assemblies that match the filter
please review the output file and refer to the Usage guide (Usage.rtf)
Mstest successfully runs from the directory :
C:\nickolay\SimpleLibrary\SimpleTestProj\bin\Release>mstest /testcontainer:SimpleTestProj.dll
Microsoft (R) Test Execution Command Line Tool Version 10.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.
Loading SimpleTestProj.dll...
Starting execution...
Results Top Level Tests
------- ---------------
Passed SimpleTestProj.SimpleClassTest.HelloWorldTest
1/1 test(s) Passed
Summary
-------
Test Run Completed.
Passed 1
---------
Total 1
Results file: C:\nickolay\SimpleLibrary\SimpleTestProj\bin\Release\TestResults\labuser.SDKiosk_SAN-D5RHRCK1 2013-07-24
21_11_00.trx
Test Settings: Default Test Settings
My head is tired of being banged up against a wall here any help is appreciated.