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 &&
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With