How to run a BOOST test using vstest.console.exe?

598 views Asked by At

I am using BOOST test to test my C++ code. The tests typically look like below and the test project is built as a exe. In order to collect Code Coverage information, I am hoping to be able to run my tests using vstest.console.exe so I can try using its /Enablecodecoverage option.

#include <boost/test/unit_test.hpp>
... other includes ...

class TestContext {...}

BOOST_AUTO_TEST_SUITE(MyTests);

    BOOST_FIXTURE_TEST_CASE(SomeTest, TestContext)
    {
        // test code 
    }

BOOST_AUTO_TEST_SUITE_END()

I keep running into "No test is available in .exe. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again." I am clueless at this point.

When running using --diagnostic option, I see this in the generated file:

"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions\TestPlatform TpTrace Warning: 0 : 13924, 3, 2020/10/15, 14:33:27.926, 1817417335033, testhost.exe, TestPluginDiscoverer: Failed to load extensions from file 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions\TestPlatform\Extensions\Microsoft.VisualStudio.Coverage.Interop.dll'. Skipping test extension scan for this file. Error: System.BadImageFormatException: Could not load file or assembly 'Microsoft.VisualStudio.Coverage.Interop' or one of its dependencies. An attempt was made to load a program with an incorrect format. File name: 'Microsoft.VisualStudio.Coverage.Interop'"

Visual Studio Installer on my machine confirms Boost.Test test adapter is already installed.

1

There are 1 answers

0
Aniruddha Gore On

Figured it out. The issue was a right TestAdapter path. I have Boost.Test adapter installed already (if you don't you can do so from VS Installer). Adapters are located on my machine in folders under C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions and vstest.console.exe is able to detect and execute tests even if I gave path to the root directory like /TestAdapterPath:"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise".