Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

test input/output of Visual Studio 2012 console application

I am working on a program which reads some input from standard-in, processes it, and writes some output to standard out. So that I don't have to type in sample/test input every time, I have saved the input to a TXT file, and the corresponding expected output to another TXT file.

How can I run my executable (preferably in either Debug or Release mode, or potentially under profiler) such that VS automatically feeds in the input TXT file? Can VS automatically check the output of the program vs the expected output TXT file? It would be great if it would show me a side-by-side diff if they are not the same. Can I set up the testing framework to run various tests with different input/expected output files?

Note that I can't just use normal unit testing since I have to do integration testing.

EDIT: for what it's worth, I'm using C++.

like image 313
Nicu Stiurca Avatar asked Nov 13 '22 03:11

Nicu Stiurca


1 Answers

As mentioned above, you can redirect input from some file.

Similarly, you can redirect output to some temporary file and then invoke some diff tool to compare your files:

In the "Command Arguments" property of "Debugging" category of project properties add:

>  actual.out.txt && diff actual.out.txt expected.out.txt

You can replace diff with any apropriate diff tool.

Generally, you can invoke any script after your program execution using &&.

like image 57
Lol4t0 Avatar answered Nov 15 '22 06:11

Lol4t0