Discussion:
Code Coverage and the Auto-Build
(too old to reply)
Steve Barker
2009-02-11 14:46:02 UTC
Permalink
Hi all,

I have a team project with continuous integration enabled. I have enabled
running of the unit tests when the build fires. I originally enabled running
of tests in a list, using the TFSBuild.proj file as follows:

<MetaDataFile Include="$(BuildProjectFolderPath)/../../Test/Test.vsmdi">
<TestList>Main</TestList>
</MetaDataFile>

…which worked fine, and produced code coverage metrics. Then I decided to
extend this to include all tests in any DLL called “*test*.dll”, so that
tests that developers forget to add to the Main test list would also be run,
by including the following additional command:

<TestContainer Include="$(OutDir)\%2aTest%2a.dll" />

This works well, so I decided that I should take out the MetaDataFile
section altogether and just use the TestContainer tag, as this would ensure
that all tests would be run and no tests would be repeated.

Code coverage metrics are calculated when tests are run using the
MetaDataFile tag, but unfortunately, the coverage is not calculated when
using just TestContainer. Is there something I need to enable/change to allow
calculation of code coverage metrics when using just TestContainer?

Many thanks,

Steve.
Hongye Sun [MSFT]
2009-02-12 11:47:30 UTC
Permalink
Hi Steve,

Thanks for your post.

If your TFS version is 2008, please follow the steps below to enable code
coverage:

1. Open build definition (TFSBuild.proj file) of your project
2. In PropertyGroup, add a property element as below:
<RunConfigFile>Location to testrunconfig file</RunConfigFile>
For example: if the testrunconfig file is located at server path:
$TeamProject1\Solution1\LocalTestRun.testrunconfig, it should be configured
in RunConfigFile element as:
$(SolutionRoot)\Solution1\LocalTestRun.testrunconfig.
Before that, you must configure the testrunconfig to enable code coverage.
3. Save the TFSBuild.proj and check into the server.
4. Trigger a build and you will see the code coverage in the build report.

In addition, if you encounter any error after adding the RunConfigFile
property. Please open the BuildLog.txt file and search for "Mstest.exe".
Checking if it has switch "/runconfig:" and if the path after it is the
correct path of testrunconfig file. Or you can directly send the
BuildLog.txt file to my email box so that I can check them for you.

Please let me know if there is anything unclear. I will try my best to
support

Regards,
Hongye Sun (***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
***@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within?2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Steve Barker
2009-02-23 17:36:01 UTC
Permalink
I think this problem is related to the other problem we're discussing, so
I'll send the files now...
Post by Hongye Sun [MSFT]
Hi Steve,
Thanks for your post.
If your TFS version is 2008, please follow the steps below to enable code
1. Open build definition (TFSBuild.proj file) of your project
<RunConfigFile>Location to testrunconfig file</RunConfigFile>
$TeamProject1\Solution1\LocalTestRun.testrunconfig, it should be configured
$(SolutionRoot)\Solution1\LocalTestRun.testrunconfig.
Before that, you must configure the testrunconfig to enable code coverage.
3. Save the TFSBuild.proj and check into the server.
4. Trigger a build and you will see the code coverage in the build report.
In addition, if you encounter any error after adding the RunConfigFile
property. Please open the BuildLog.txt file and search for "Mstest.exe".
Checking if it has switch "/runconfig:" and if the path after it is the
correct path of testrunconfig file. Or you can directly send the
BuildLog.txt file to my email box so that I can check them for you.
Please let me know if there is anything unclear. I will try my best to
support
Regards,
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within?2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Hongye Sun [MSFT]
2009-02-24 09:11:20 UTC
Permalink
Hi Steve,

Thanks for your reply.

I have responsed your email. Please do not hesitate to let me know if the
problem still exists after the other issue is fixed. Thanks.

Have a nice day!

Regards,
Hongye Sun (***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
***@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
Loading...