Skip to content

REST Unit Test Failure with GTest #1076

@joesulewski

Description

@joesulewski

Hello,

I wrote unit tests to exercise the REST calls with Google Test framework GTest. I have numerous test suites that are testing the REST calls using the virtual server, everything was working perfectly but something changed and I'm not sure what. When I run GTest every test case in one of my Test classes throws the following error:

unknown file: error: C++ exception with description "[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]: Error. Call to getaddrinfo() failed." thrown in the test fixture's constructor

If I run just that test class, the test works perfectly and passes. To summarize, suppose I have two test classes once tests REST calls, called TestRESTClass1 and the other TestClass2. If I run TestRESTClass1 and TestClass2 then TestClass2 throws the above error. If I run just TestClass2 it runs perfectly.

Here is the kicker, TestClass2 doesn't test REST calls or use any OAT classes but yet it throws that error.

I'm thinking I'm missing something when TestRESTClass is torn down?

During construction of TestRESTClass1 I start an OAT Server like so

TestRESTClass1(){
    ...
    thread = std::make_shared<std::jthread>(&TestRESTClass1::run, this);
}

void TestRESTClass1::run(){
    server=std::make_shared<oatpp::network::Server> (serverConnectionProvider, connectionHandler);
    server->run();
}

The destructor calls:
server->stop();

Thanks,
Joe

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions