简体   繁体   中英

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++.

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 && .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM