Unit tests are disappeared from VS Code Activiy Bar

User avatar
kozmotronik
Posts: 5
Joined: Wed Jan 29, 2025 8:28 am

Unit tests are disappeared from VS Code Activiy Bar

Postby kozmotronik » Tue Feb 11, 2025 7:26 am

Hi there, ESP noob here.

I am trying to create a custom component with its unit tests in VS Code. The test cases were visible in the Activity Bar > Testing section at first. Then suddenly the tests have been disappeared as I keep developing the component. I've tried building and flashing the test app. It did built, but no test listed in the test menu.
Here how it looks in the UI:
vscode_espidf_no_tests.png
Screenshot image
vscode_espidf_no_tests.png (174.57 KiB) Viewed 215 times
This is how the test menu looks in the terminal output after flashing and monitoring:

Code: Select all

Press ENTER to see the list of tests.



Here's the test menu, pick your combo:

Enter test for running.

If the directory structure would be a concern, then the following is the directory structure of the whole project:

Code: Select all

custom_component
├── CMakeLists.txt
├── components
│   └── relay_chn
│       ├── CMakeLists.txt
│       ├── idf_component.yml
│       ├── include
│       │   └── relay_chn.h
│       ├── Kconfig
│       ├── relay_chn.c
│       └── test
│           ├── CMakeLists.txt
│           ├── main
│           │   ├── CMakeLists.txt
│           │   ├── relay_chn_test.c
│           │   └── relay_chn_test_main.c
│           └── sdkconfig.defaults
├── main
│   ├── CMakeLists.txt
│   └── main.c
├── README.md
├── sdkconfig
├── sdkconfig.old
└── unity-app
    ├── CMakeLists.txt
    ├── conftest.py
    ├── dependencies.lock
    ├── main
    │   ├── CMakeLists.txt
    │   └── test_app_main.c
    ├── sdkconfig
    ├── sdkconfig.defaults
    ├── sdkconfig.old
    └── test_unit_case.py
Update 25-02-14 - Added git repo link
The public git repo link -> https://gitea.kozmotronik.com.tr/Kozmot ... /relay_chn

What should I do to make the tests appear in the Testing tab of the activity bar? I can share the contents of files, or better can make it a public git repo if required. Any kind of help is highly appreciated.
Last edited by kozmotronik on Mon Feb 17, 2025 2:45 pm, edited 2 times in total.

ESP_bignacio
Posts: 234
Joined: Wed May 02, 2018 12:12 pm

Re: Unit tests are disappeared from VS Code Activiy Bar

Postby ESP_bignacio » Mon Feb 17, 2025 8:47 am

The reason why test don't show in the Testing tabs is because it is not following the naming convention of test files. The extension automatically find tests in files of name test_*.c as described in unit testing documentation

User avatar
kozmotronik
Posts: 5
Joined: Wed Jan 29, 2025 8:28 am

Re: Unit tests are disappeared from VS Code Activiy Bar

Postby kozmotronik » Mon Feb 17, 2025 9:09 am

ESP_bignacio wrote:
Mon Feb 17, 2025 8:47 am
The reason why test don't show in the Testing tabs is because it is not following the naming convention of test files. The extension automatically find tests in files of name test_*.c as described in unit testing documentation
Hello Bignacio, thank you for your answer.
As a matter of fact, I've renamed the test files when I noted the naming convention mentioned in the documentation after I posted this post. Sorry for that I did not update the post accordingly.
This is how my project directory structure looks like at the moment but the extension still does not detect the tests.

Code: Select all

$ tree -I build
.
├── CMakeLists.txt
├── components
│   └── relay_chn
│       ├── CMakeLists.txt
│       ├── idf_component.yml
│       ├── include
│       │   └── relay_chn.h
│       ├── Kconfig
│       ├── LICENSE
│       ├── README.md
│       ├── src
│       │   └── relay_chn.c
│       └── test
│           ├── CMakeLists.txt
│           ├── main
│           │   ├── CMakeLists.txt
│           │   └── test_relay_chn.c
│           └── sdkconfig.defaults
├── dependencies.lock
├── main
│   ├── CMakeLists.txt
│   └── main.c
├── README.md
├── sdkconfig
├── sdkconfig.old
└── test
    ├── CMakeLists.txt
    └── main
        ├── CMakeLists.txt
        └── test_relay_chn_main.c

10 directories, 21 files
As you can see, I renamed it as test_relay_chn.c, but still no avail.
Then I added the main level test directory in the intent of createing a similar directory structure of the unit test example. This did not change the situation either. What could be the problem? May be one of the CMakeLists files?

Who is online

Users browsing this forum: No registered users and 23 guests