简体   繁体   English

使用C#测试C ++代码时的代码覆盖率

[英]Code Coverage when testing c++ code using c#

Here's the situation: 情况如下:

I am writing unit tests in C# for C# code that calls functions written in C++/CLI which in turn call functions that are written in C++. 我正在用C#为C#代码编写单元测试,这些代码调用用C ++ / CLI编写的函数,而这些函数又调用用C ++编写的函数。 The C++/CLI code and the C++ code are in a different solution than the one the C# code is in. C ++ / CLI代码和C ++代码在与C#代码所在的解决方案不同的解决方案中。

The unit test runs successfully. 单元测试成功运行。

However, it only supplied code coverage analysis for the C# module. 但是,它仅提供C#模块的代码覆盖率分析。 The DLL for the C++/CLI code and it's PDB file are both in the same folder as the Unit testing DLL. C ++ / CLI代码的DLL及其PDB文件与单元测试DLL都位于同一文件夹中。 (The C++ code does not have a DLL, it has a LIB file). (C ++代码没有DLL,它具有LIB文件)。

What should I do in order to get code coverage analysis for the C++/CLI and the C++ code? 为了获得C ++ / CLI和C ++代码的代码覆盖率分析,我应该怎么做?

If you're referring to Visual Studio's code coverage - it should work with C++. 如果您指的是Visual Studio的代码范围-它应该与C ++一起使用。 I think you need to have the C++ source code as part of the solution so that the specific run would add hooks and gather coverage information. 我认为您需要将C ++源代码作为解决方案的一部分,以便特定的运行将添加挂钩并收集覆盖率信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM