Ceedling icon indicating copy to clipboard operation
Ceedling copied to clipboard

Include code file instead of header for file under test

Open dwijtsma opened this issue 3 years ago • 4 comments

When I include the header file of the file I want to unit test, everything is fine. When I include the code file of the file I want to unit test, the .gcda and .gcno and .o file are missing from build/gcov/out.

In the command line I get instead of the coverage:

---------------------------
GCOV: CODE COVERAGE SUMMARY
---------------------------
build/gcov/out/main.gcno:cannot open notes file
build/gcov/out/main.gcda:cannot open data file, assuming not executed

I also attached two ceedling projects, so it is easy to reproduce: ceedling tests.zip

I run WSL on Windows 10: Python 3.8.10 ruby 2.7.0p0

Ceedling:: 0.31.1 Unity:: 2.5.4 CMock:: 2.5.4 CException:: 1.3.3

I hope this can be resolved or if someone can help me to make it work.

dwijtsma avatar Jul 08 '22 22:07 dwijtsma

Why are you including the source file in the test?

ajc-novo avatar Aug 19 '22 23:08 ajc-novo

Including the code file instead gives the possibility to test the internals, which is something I sometimes like to do.

Next to that we have already a lot of unit tests written in the past. We use CMock, Unity and GCOV. A good amount of those tests include the c file. I would like to get rid of the scripts we use to automate that all.

I love the work that has been put into Ceedling. 😃

dwijtsma avatar Aug 22 '22 19:08 dwijtsma

I agree with the argument to include the .c file. However this was posted as an "issue" that ceedling could not find the source file to be tested. The solution is TEST_FILE which is not really documented.

ajc-novo avatar Aug 22 '22 19:08 ajc-novo

I have the same issue with a code base that makes extensive use of static functions. Has the solution to this been documented yet? If not, could you please expand on what's meant by the statement:

The solution is TEST_FILE

Thank you.

JCordara avatar Jun 20 '24 21:06 JCordara