If these files are also the input from which actual_value is calculated, then what you are doing is testing an alternative implementation and a real one. This is true, but requires an understanding of things ahead, for example, this is usually done with a very simple and easy to verify test implementation compared to an optimized and more complex "production" implementation. If this is not the case, you are doing something wrong.
If the files contain results that actual_value not calculated from now, this should be normal, for example, if you have sets of inputs and corresponding sets of the expected result.
Also, consider whether you can overtake at least a few cases of trivial hard-coded input and hard-coded expected output similar to your first example, and not to files. This may require that your interface work with an abstraction that is not File in order to simulate input, or be able to introduce an alternative mechanism for reading files into those tests that actually serve to test the test data.
EDIT: Just to provide a concrete example of using large abstractions instead of File instances (or file names or something else), consider using okio and passing in a set of Source instances.
Real implementation : a list of instances of File , create instances of Source using Okio.source (file) .
Tests : pass a list of Buffer instances containing whatever you want
Buffer b = new Buffer(); b.writeUtf8("whatever the hell I want in this file"); // can also write bytes or anything else int actualValue = getRelevantLinesOfFiles(Arrays.asList(b));
source share