I am trying to determine the best way to write testable code. Here's my code
class FileReader {
private FileInputStream input;
public FileReader(FileInputStream input) {
this.input = input;
}
public void read() throws IOException {
Row row = readHeaderRow();
Row[] rows = readOtherRowsBasedOnHeader(row);
doSomethingElse(rows);
}
private void readHeaderRow() {
//..
}
private void readOtherRowsBasedOnHeader(Row row) {
//..
}
private void doSomethingElse(Row[] rows) {
//..
}
}
as you can see from above, only the read() method is public. Rest of the methods are private. Should I just leave private methods out from testing? Or does it make sense to make all methods public and do what read() is doing in the calling code?