locked
Passing command line argument to test runner. RRS feed

  • Question

  • My setup is Visual Studio 2015 with the gtest test runner

    https://visualstudiogallery.msdn.microsoft.com/94c02701-8043-4851-8458-34f137d10874

    Everything works fine. But now I want to pass command line arguments to

    int main(int argc, char **argv) {..}
    

    When debugging I can pass them with Properties->Debugging->Command Argument. That works fine.

    I can run the test with Test->Run->Selected Test but how can I pass the command line arguments to the test by using the test explorer? It's not taking over the debugging Command Arguments.

    Wednesday, December 16, 2015 9:39 AM

Answers

  • Hi acinfo32,

    Sorry for misunderstanding your origin post. My understanding for your origin post is pass command line parameters from gtest.

    >>The question is about how to pass command line parameters to the Visual Studio test runner from the IDE?

    Please add your command line arguments in Build Events of your project, which can add from Project Properties window -> Build Events as below image shows. Every time when we run our test in Test Explorer, it will build the test project automatically.

    Best Regards,
    Weiwei

    Tuesday, December 22, 2015 5:14 AM

All replies

  • Hi acinfo32,

    Welcome to MSDN forum.

    This forum is discuss Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor.

    Since your problem is more related to Google Test Adapter, I suggest post your problem under Q&A where the author will notice this issue.

    In addition, I find you have post the same question on Stack Overflow and legalize has provide some tips for you. I will quote the thread here. If the tips from legalize is helpful, please mark his/her reply as answer, which is benefit to other communities who has the same problem.

    http://stackoverflow.com/questions/34159984/passing-command-line-arguments-to-gtest-test-runner-in-vs2015

    Best Regards,
    Weiwei

    Thursday, December 17, 2015 9:59 AM
  • Dear Weiwei,

    Thank you for your reaction. Some remarks:

    1 - The person on Stack Overflow recommended to post a question in this VS forum because he didn't know a answer. It seems no one there knows and it's unclear from the documentation. So I have nice tips but no answer to my question where I'm now looking for.

    2 - I use the google test but the question is about the test runner. I think this also holds for NTest and all other test runners.

    The question is about how to pass command line parameters to the Visual Studio test runner from the IDE? I cannot find it via the properties of the project, nor in the test settings. Maybe via runsettings but I have no idea if and how.

    Regards

    Friday, December 18, 2015 8:04 AM
  • Hi acinfo32,

    Sorry for misunderstanding your origin post. My understanding for your origin post is pass command line parameters from gtest.

    >>The question is about how to pass command line parameters to the Visual Studio test runner from the IDE?

    Please add your command line arguments in Build Events of your project, which can add from Project Properties window -> Build Events as below image shows. Every time when we run our test in Test Explorer, it will build the test project automatically.

    Best Regards,
    Weiwei

    Tuesday, December 22, 2015 5:14 AM
  • How are Build Events used to create run time command line arguments for unit tests? When I add
    /postbuild:post
    As a Post-build event, I get
    Error The command "/postbuild:post" exited with code 123.

    And a similar error message if I try as a Pre-build event.

    Please advise with a specific example of how this can work. Thanks.


    Regards Brewmanz

    Tuesday, July 2, 2019 12:59 AM