vtest.console.exe does not find any C++ test in test project Visual Studio 2022 (did in 2019)

RFOG 1 Reputation point
2022-09-13T14:04:03.73+00:00

I have a solution of 52 projects mixed with C#, MFC and C++/CLI working with Visual Studio 2019. Recently I retargeted it to Visual Studio 2022 and moved all C++ projects to C++20. This solution has two test projects: one .NET only and a second one (the main one) native (but some code is C++/CLI). Both are DLL. Visual Studio is 17.3.3.

In VS2019, the test framework detected all tests without problem, but VS2022 does not detect any test. Manually running the tests: vstest.console.exe .\PolarisUnitTests.dll /Platform:x86 /diag:diag.txt, returns:

Microsoft (R) Test Execution Command Line Tool Version 17.3.0-preview-20220626-01 (x64)
Copyright (c) Microsoft Corporation. All rights reserved.

Starting test execution, please wait...
Logging Vstest Diagnostics in file: D:\src\software\Polaris\testing\Debug\diag.txt
A total of 1 test files matched the specified pattern.
No test is available in D:\src\software\Polaris\testing\Debug.\PolarisUnitTests.dll. Make sure that test discoverer & executors are registered and > platform & framework version settings are appropriate and try again.

Additionally, path to test adapters can be specified using /TestAdapterPath command. Example /TestAdapterPath:<pathToCustomAdapters>.

Generated logs do not contain any errors. The problem is that Test Framework does not find any test into the DLL. Running this DLL with Command Line Test Tool v. 16.11.0 still does not find any test, then I assume the issue is in the compiler/linker not putting the right metadata.

Any idea how to resolve this? Thanks.

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,761 questions
Visual Studio Testing
Visual Studio Testing
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Testing: The act or process of applying tests as a means of analysis or diagnosis.
351 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.