I am aware that this might be a duplicate (forgive me if that is the case), any one of these two could be a duplicate to what I'm searching for, but as I have no idea if they do answer my problem I'll ask it here anyway.
JUnit test for console input and output,
JUnit test for System.out.println()
My assignment (school):
We're to write a simple compiler that tracks the colour of a pencil and movement across the x- and y-axis. i.e.
Input:
% This is a comment
% Now we're making a square
DOWN.
FORW 1. LEFT 90.
FORW 1. LEFT 90.
FORW 1. LEFT 90.
FORW 1. LEFT 90.
Output:
#0000FF 0.0000 0.0000 1.0000 0.0000
#0000FF 1.0000 0.0000 1.0000 1.0000
#0000FF 1.0000 1.0000 0.0000 1.0000
#0000FF 0.0000 1.0000 0.0000 0.0000
My problem:
To get a passing grade our code is subjected to a rigorous series of tests, many of these give you no clue as to what went wrong. i.e.
"A random generated program on 1215 bytes, with 1 syntax error"
So I feel that a great part of this assignment is to learn how to write good test-code, I've been thinking about trying to use JUnit (or perhaps I should use something else?). My input comes from System.in and the output goes through System.out.println().
Hopefully there is a way to do this by using existing textfiles (went through some difficulties earlier with assertEquals and super long strings full of \n). To clarify: I want to test I/O (through text-files) of my Java-program and I can't find any good clear explanation on how I can do this.