Suggestions on how to test a BufferedReader and FileReader that takes in strings and puts them into an ArrayList
<p>I have a class which has a method that reads a text file line by line and then puts each line into an <code>ArrayList</code> of Strings. Here is my code:</p>

<pre><code>public class ReadFile {

    public List&lt;String&gt; showListOfCourses() throws IOException {
        String filename = "countriesInEurope.txt";
        FileReader fr = new FileReader(filename);
        BufferedReader br = new BufferedReader(fr);
        List&lt;String&gt; courseList = new ArrayList&lt;&gt;();

        while (true) {
            String line = br.readLine();
            if (line == null) {
                break;
            }

            courseList.add(line);
        }
        br.close();

        return courseList;
    }

}
</code></pre>

<p>I was hoping for a few suggestions on how to test this method through <code>Mockito</code> involving Arrange/Act/Assert. I have heard readers which involve text files can be tricky to test and that creating a temporary file for is not best practice as it uses up memory? Any suggestions will be really appreciated.</p>