How to Analyze a Project AND its Unit Test

Hello,

i have a Project here:

Sonar Lint works fine here:
https://sonarcloud.io/project/overview?id=Meisterschulen-am-Ostbahnhof-Munchen_cci_EasyExample

so, now:
i add a UNIT Test, using unity,
description here:
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/unit-tests.html

so, the Project is here:

the Test Runner is here:

in the Moment the

File only builds the Main Application but not the Test Runner.

how to build the Test Runner also, and also build-wrap an analyze it ?

Thanks,
Franz

Hello @franz-ms-muc,

Sorry for the late reply.
Are you still facing the issue?
We analyze the files that are built by the command wrapped with build-wrapper and indexed by the sonar-scanner.
To analyze the source and test file, the command provided to build wrapper should cleanly build both of them. you can combine the two in one script and wrap it.

You can look at the generated JSON file to see the compilation command captured by build-wrapper.
Let me know if you have further questions,
Thanks,

how can i FIRST build the App,
then Build the Tests ?

it is 2 Build Commands.
how to do ?

so to make it more clear:

i must issue a

idf.py build in the Main Folder,
and a
idf.py build in the Unit Tests Folder ?

how can this be done ?

it is calling the Script 2 times in different Folders ?

Hello @franz-ms-muc,

I’m not sure I understand the issue you are facing.

Let’s try to follow your example:

In this case, if you want to analyze both source and test I would create a script that runs both. Let’s say BuildAndTest.sh that call idf.py build and idf.py test.

Then instead of calling:
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} idf.py build

i would call:
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} ``` bash BuildAndTest.sh

Does that answer your question?

Thanks,

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.