How to test using gtest function main(argc, argv[])?

How to test a small application with the help of the Google test. To test from the main function depending on the input parameters argc and argv.
March 25th 20 at 13:14
2 answers
March 25th 20 at 13:16
Solution
In fact it turns out that you write a system test. Consequently, you should have already compiled application.
The easiest option in this case -- it just call the application using std::system , and test the output. As std::system just returns the exit code, output you can write to any file. And then, as in the usual test, to compare what happened and what should happen. In fact you have two applications: the test itself and the tool you are testing.
March 25th 20 at 13:18
@amparo_Kertzmann,
Start -> in the example VS
https://docs.microsoft.com/ru-ru/visualstudio/test...

To test from the main function depending on the input parameters argc and argv.

not quite clear what to test the main function? But here is an example from documentation
https://github.com/google/googletest/blob/master/g...
Well, that is a console application that takes parameters argc argv.
To specify a list of parameters and check the data output from the application using googletest - amparo_Kertzmann commented on March 25th 20 at 13:21
@amparo_Kertzmann,
the data output from the application

data is written to stdout?
then test need to transfer them there. - kaci.Senger55 commented on March 25th 20 at 13:24
Error to stdout and to a file.
How to set argc argv to gtest framed them in main function - amparo_Kertzmann commented on March 25th 20 at 13:27
@amparo_Kertzmann,
How to set argc argv to gtest framed them in main function

Well, there it is certainly possible to pass parameters but it's kind of not how it works.
https://github.com/google/googletest/blob/master/g... - kaci.Senger55 commented on March 25th 20 at 13:30

Find more questions by tags Development through testingModular testingC++