Semant1ka
Semant1ka

Reputation: 687

How to force gtest write report to xml from Init

For some reason, I can't start gtest tests from commandline, so I can't pass any arguments to it. I want to run InitGoogleTest already with a parameter defined in code. Somewhere on the Internet I found a solution like this:

int main(int argc, char **argv) {
char *option[] = { "test.exe", //it doesn't have meaning, just dummy
                   "--gtest_output=xml:filename" };
int argc1 = 2;
  ::testing::InitGoogleTest(&argc1, option);
  return RUN_ALL_TESTS();
}

This solution didn't produce any errors but didn't create any xml with report either. Can anyone suggest how to force gtest to write xml from Init?

Upvotes: 3

Views: 3869

Answers (1)

VladLosev
VladLosev

Reputation: 7736

You can override the output flag by adding

::testing::GTEST_FLAG(output) = "xml:filename";

before the call to InitGoogleTest. You can read more on it at Google Test docs.

Upvotes: 3

Related Questions