I am attaching a MSVC9 project. This project has a Default Package with a single class. I created 2 test architectures and trying to do code coverage,
1, In TPkg_class_0 , it is using default package as a library , and when i add a test case and try building it ,it gives linking error:
TCon_class_0.obj : error LNK2019: unresolved external symbol "void __cdecl class_01_osc_goals_evaluate(int)" (?class_01_osc_goals_evaluate@@YAXH@Z) referenced in function "public: void __thiscall TCon_class_0::dump_code_coverage(void)" (?dump_code_coverage@TCon_class_0@@QAEXXZ)
TPkg_class_0_Comp.exe : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: '"c:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\link.exe"' : return code '0x460'
2. In TPkg_class_0_1, class_0 is in scope of test project. Now i am able to build the project as well and also code coverage is computed.
However i want to use my package as a library. What change should i make so that i can do code coverage even when i am using library and not building SUT in scope of test project.
I am attaching my model as well.
Pinned topic Test Conductor(code coverage) issue in assertion mode
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2012-12-10T14:40:22Z at 2012-12-10T14:40:22Z by chr_btc-es
RichaM 270002DMXT70 Posts
Re: Test Conductor(code coverage) issue in assertion mode2012-12-10T11:14:10ZThis is the accepted answer. This is the accepted answer.I would like to add one more point to my query, when i am using SUT in a library, and CoverageKind : SUT_Flat or SUT_Hierarchical. tmp folder is not getting generated, Annotation does not start.
However when I change coveragekind to TestContext_Flat or Hierarchical, in this case, annotation starts and tmp creates but for TestComponent class and TCON class and again not for SUT. So linking error is still there.
chr_btc-es 270002EDQ984 Posts
Re: Test Conductor(code coverage) issue in assertion mode2012-12-10T14:40:22ZThis is the accepted answer. This is the accepted answer.
- RichaM 270002DMXT
to be able to compute code coverage, the source code must be instrumented (annotated) with additional code to collect the coverage data before the code is compiled. If you create a library for the SUT, the library does not contain the needed annotation. This causes the linker error because expected functions like TCon_class_0::dump_code_coverage do not exist in the library for the SUT.
Computing code coverage for a SUT in a library is not supported out of the box.