matepek / vscode-catch2-test-adapter

Catch2, Google Test and doctest Adapter for the VSCode
https://marketplace.visualstudio.com/items?itemName=matepek.vscode-catch2-test-adapter
MIT License
209 stars 52 forks source link

GoogleTest messages printed in global tear down are not shown in TestResults output #442

Closed maximiliank closed 2 weeks ago

maximiliank commented 2 months ago

Checklist

Describe the bug

I am using gtest with global setup and tear down as described here https://google.github.io/googletest/advanced.html#global-set-up-and-tear-down. My main.cpp looks like

#include <gtest/gtest.h>
#include <iostream>

TEST(MyTest, Test)
{
    ASSERT_TRUE(true);
}

class GlobalEnvironment : public ::testing::Environment {
  public:
    ~GlobalEnvironment() override {}

    void SetUp() override
    {
        std::cout << "GlobalEnvironment set up" << std::endl;
    }

    void TearDown() override
    {
        std::cout << "GlobalEnvironment tear down" << std::endl;
    }
};
int main(int argc, char** argv)
{
    ::testing::InitGoogleTest(&argc, argv);
    ::testing::AddGlobalTestEnvironment(new GlobalEnvironment());
    return RUN_ALL_TESTS();
}

When I run the tests via the extension and look at the TestResults output it only prints the message from SetUp() and not the message from TearDown(), e.g.:

$1β”‚ Started PID#1234 - '/home/user/out/build/unixlike-gcc-debug/test/tests'
$1β”‚ 
$1β”‚ GlobalEnvironment set up
$1β”‚ [ RUN      ] MyTest.Test @ ./test/main.cpp:4
$1β”‚ [       OK ] MyTest.Test (0 ms)
$1β”‚ 
$1β”‚ Stopped PID#1234 - Exit(0) / OK - '/home/user/out/build/unixlike-gcc-debug/test/tests'

When I run it from the command line it prints also the TearDown() message:

$ out/build/unixlike-gcc-debug/test/tests --gtest_color=no
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
GlobalEnvironment set up
[----------] 1 test from MyTest
[ RUN      ] MyTest.Test
[       OK ] MyTest.Test (0 ms)
[----------] 1 test from MyTest (0 ms total)

[----------] Global test environment tear-down
GlobalEnvironment tear down
[==========] 1 test from 1 test suite ran. (0 ms total)
[  PASSED  ] 1 test.

To Reproduce

Compile given main.cpp with gtest.

Screenshots (optional)

Desktop

Regression bug?

Not that I am aware of.

**Log** (optional but recommended) ```js ```
matepek commented 2 weeks ago
Fixed in v4.12.1. This issue was mentioned in [CHANGELOG.md](./CHANGELOG.md) under a released entry so it is assumed to be fixed. User verifications are always welcome.