0

I'm new to both vcpkg and boost library and I've been researching, and trying, how to setup boost-unit-tests-framework on VS 2019 but all docs seem out of date.

My goal is to run boost tests from test explorer in visual studio.

Vcpkg

  1. Cloned Vcpkg and ran bootstrap-vcpkg.bat
  2. Ran vcpkg integrate install to configure Visual Studio with the library and include paths of the installed packages

Compiling tests [Debug only]

Following: ms-docs

  • Installed boost-test package using vcpkg install boost-test:x64-windows-static
  • Added the following elements to the <PropertyGroup Label="Globals"> in my unit test project:
   <VcpkgTriplet>x64-windows-static</VcpkgTriplet>
   <VcpkgEnabled>true</VcpkgEnabled>
  • Set C/C++ -> Code Generation -> Runtime Library to Multi-threaded Debug (/MTd)
  • Added Additional include directories -> $(VcpkgRoot)include\ that resolves to C:\vcpkg\installed\x64-windows-static\include\
  • Added Linker -> Additional Library Directories -> $(VcpkgRoot)debug\lib\ that resolves to C:\vcpkg\installed\x64-windows-static\debug\lib\
  • Added Linker -> Input -> Additional Dependencies -> boost_unit_test_framework-vc140-mt-gd.lib;boost_regex-vc140-mt-gd.lib;boost_exception-vc140-mt-gd.lib;boost_container-vc140-mt-gd.lib;%(AdditionalDependencies)
  • Added test code:
    #define BOOST_TEST_MODULE MyTest
    #include <boost/test/included/unit_test.hpp>
    #include <string>

    class MyClass
    {
        std::string m_name = "Jim";
    public:
        std::string get_value() const { return m_name; }
        void set_value(std::string const &name) { m_name = name; }
    };

    BOOST_AUTO_TEST_CASE(my_boost_test)
    {
        std::string expected_value = "Bill";

        MyClass mc;
        BOOST_CHECK(expected_value == mc.get_value());
        BOOST_TEST(expected_value == mc.get_value());
        mc.set_value(expected_value);
        BOOST_TEST(expected_value == mc.get_value());
    }

Console run

Everything runs fine running the test exe from console: enter image description here

VS Test explorer

Nothing shows up on the test-explorer, even if my boost test-adapter is intalled.. empty-test-explorer

Has anyone solved this yet??

One alternative I've found is to run the test.exe as part of the build process like boost-docs mention. Not quite as useful for my team.

L4ZZA
  • 83
  • 12
  • On the bottom panel (the output), it says `show output from build`. This is a drop down, and I believe there is another option for the output. On the left side, there is a `play` button, doesn't it run all the discovered boost.test modules? – Raffi May 09 '20 at 18:13
  • From the test viewer on the left you can see it does not discover the tests. – L4ZZA May 10 '20 at 10:48

0 Answers0