L
L
Lo-st2019-08-04 08:15:38
C++ / C#
Lo-st, 2019-08-04 08:15:38

How can I test the main(argc, argv[]) function with gtest?

How to test a small app with google test. Test the main function right away depending on the input parameters argc and argv.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly, 2019-08-04
@Lo-st

In fact, it turns out that you are writing a system test. Therefore, for it you need an already compiled application.
The easiest option, in this case, is to simply call the application with std::system and check the output. Since std::system simply returns an exit code, the output can be written to a file. Well, then, as in a regular test, compare what happened and what should happen. In fact, you have two applications: the test itself and the utility you are testing.

R
Roman, 2019-08-04
@myjcom

Lo-st ,
Beginning -> on VS example
https://docs.microsoft.com/en-us/visualstudio/test...
it is not entirely clear what it means to test the main function? But here is an example from the documentation
https://github.com/google/googletest/blob/master/g...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question