Automated testing

OK, so this is what I need to do:
I have a C++ program.
I have different text files, that the program uses as input files, 1 program run - 1 input file.
I have also text files with the correct output lines for each input file, 1 program run - 1 output file.

Is it possible, by using some tool, to perform an automated testing?
This tool uses my input text files and creates the output files, and then compares the output files, to the ones that I have?

Example

Files that I have:

1.in:
STR 4 8
STR a b
Q

1.out:
48
ab
ok

Files that the tool uses and runs the program:
1.in

Tool creates output file tool1.out
Tool compares 1.out to tool1.out
If they match, then the test is OK.
Sure. You could also write a unit test to test the logic inside the program independent of the file access.

http://www.boost.org/doc/libs/1_49_0/libs/test/doc/html/index.html
Last edited on
Thanks, but what tool should I use to test the test files?
Hm.. Still no response...
I guess you'll have to write an application to do that, but if you're already creating unit tests for you initial tool then testing the file is a little useless (if that makes sense).
Aren't there any programs, where I can select the input files for program, and then the output files would be compared to the ones I have?
closed account (4z0M4iN6)
I think, for 1.in -> tool1.out you could use a C++ program.

This C++ program wouldn't need any file access, only input a line from standard input, the conversion (STR 4 8 to 48) and print a line and this for all lines of the file which should be converted.

Lets call it ConvertFile.exe

Then you open a new text document like Yourtest.txt and write the following lines:

1
2
type 1.in | ConvertFile.exe > tool1.out
comp tool1.out 1.out

After you have typed this, close the file and rename it to Yourtest.cmd.

And then you type in the console window: Yourtest
Last edited on
man wrote:
diff - compare files line by line
-q, --brief
report only when files differ
I know, that i could write a C+ program to do that.
But, the goal is to show, that I can use some other testing tool, that can do this automatically...
A shell script or even makefile could do this for you. The easiest way may be to have a separate file that contains your expected output and diff the result against it.
closed account (4z0M4iN6)
comp tool1.out 1.out

Why discuss so much, simply: try

This are only 20 keystrokes. And should take only some seconds.

You could have this implemented already, and could have marked this topic as solved!
Last edited on
Topic archived. No new replies allowed.